Friday, September 14, 2012

Loadrunner Convert To Unicode or UTF-8

The following shows how to convert strings in Vugen to unicode or UTF-8, which is necessary for certain applications with globalization functionality.

Script


Action() 

char *converted_buffer_unicode = NULL; 

// convert to unicode
lr_convert_string_encoding("Text to convert to unicode", 
LR_ENC_SYSTEM_LOCALE, 
LR_ENC_UNICODE, 
"paramUnicode"); 

// convert to UTF-8
lr_convert_string_encoding("Text to convert to utf8", 
LR_ENC_SYSTEM_LOCALE, 
LR_ENC_UTF8, 
"paramUtf8"); 

return 0; 




Console Output


Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(6): Notify: Saving Parameter "paramUnicode = T\x00e\x00x\x00t\x00 \x00t\x00o\x00 \x00c\x00o\x00n\x00v\x00e\x00r\x00t\x00 \x00t\x00o\x00 \x00u\x00n\x00i\x00c\x00o\x00d\x00e\x00\x00\x00".
Action.c(12): Notify: Saving Parameter "paramUtf8 = Text to convert to utf8\x00".
Ending action Action.
Ending iteration 1.

No comments:

Post a Comment