脚本录制后显示乱码,Recording option->Advanced选择了支持UTF-8,无法解决,导致在某些数据时由于无法完全转换为中文从而显示为乱码,而乱码直接改为中文是无法正确提交的,原提交脚本如下:
web_custom_request("Manager!saveItem.action",
"URL=http://192.168.0.1/saveItem.action?xmlParam=<data><row addr=\"鏉\xAD\xE5窞甯傛枃鏅栬矾321鍙\"</data>",
"Method=POST",
"RecContentType=text/html",
"Mode=HTML",
"EncType=text/xml; charset=UTF-8",
LAST);
解决方法使用字符编码格式转换函数:
char tmp[30];
lr_convert_string_encoding("单位地址",LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"yyy");
strcpy(tmp,lr_eval_string("{yyy}"));
lr_save_string(tmp,"xxx");
web_custom_request("Manager!saveItem.action",
"URL=http://192.168.0.1/saveItem.action?xmlParam=<data><row addr=\"{xxx}\"</data>",
"Method=POST",
"RecContentType=text/html",
"Mode=HTML",
"EncType=text/xml; charset=UTF-8",
LAST);