关于 LoadRunner 脚本中乱码的处理
2019-04-10 本文已影响9人
wqching
LoadRunner 11 并不支持中文字符的识别,很苦恼
使用 LR 自带函数将中文进行封装
这是一种比较”正统”的解决方案(亲试过,不见效)
中文转化为 UTF-8
> lr_convert_string_encoding converts a string encoding between the following encodings: System locale, Unicode, and UTF-8. The function saves the result string, including its terminating NULL, in the parameter paramName.
> Printable characters in the result string are displayed in VuGen and its logs as the actual characters. Non-printable characters are displayed in Hexadecimal. For example:
> rc = lr_convert_string_encoding("A", NULL, LR_ENC_UTF8, "stringInUnicode");
> The result string displays as A\x00, and not \x41\x00, because the letter A is a printable character.
> Add lr_convert_string_encoding manually to a script when needed. It is not recorded.
> Possible values for 'fromEncoding' and 'toEncoding' :
----
__示例__
```char tmp[100];
lr_convert_string_encoding("测试账户",LR_ENC_SYSTEM_LOCALE, LR_ENC_UTF8, "Account");
strcpy(tmp,lr_eval_string("{Account}"));
lr_save_string(tmp,"Account");
web_submit_data("login.quick",
……
"Name=account", "Value={Account}", ENDITEM,
……
LAST);
得到正确中文的乱码,以乱码字符进行传输
这是一个利器,屡试不爽,此处只写一个思路。
在服务器中填写你所需要的中文字符,通过 LoadRunner 接口去调取,在 日志信息中,查找所要的中文字符经过 LoadRunner 处理后的乱码,拷贝到脚本中即可。