服务器返回中文乱码的情况(UTF8编码 -> 转化为 SYSTEM_LOCALE 编码)
服务器乱码 转换使用如下方法
入惨{“msg”} -> utf8编码 -> 转化为 SYSTEM_LOCALE 编码 -> 接受转换后的参数 "sEncoding"
lr_convert_string_encoding(lr_eval_string("{msg}") , LR_ENC_UTF8 , LR_ENC_SYSTEM_LOCALE , "sEncoding");
1 Action()
{
//服务器 返回中文乱码的 情况 // 2.注册函数+strcmp web_reg_save_param("msg",
"LB=message\":\"",
"RB=\"",
"Ord=1",
LAST); lr_start_transaction("post_json2"); //json接口需要加header请求头
web_add_header("Content-type", "application/json"); web_custom_request("post_json", "Method=POST", "URL=http://localhost:8080/pinter/com/register", "Body={\"userName\":\"test\",\"password\":\"1234\",\"gender\":1,\"phoneNum\":\"110\",\"email\":\"beihe@163.com\",\"address\":\"beijing\"}", "TargetFrame=", LAST ); // //由于message返回为乱码字符串无法判断?需要作编码转化。
// 因为msg 是内部函数 需要转化为c语言的函数使用, LR_ENC_UTF8-->LR_ENC_SYSTEM_LOCALE 又变成了 lr的函数,因为是lr帮你存的 lr_convert_string_encoding(lr_eval_string("{msg}") , LR_ENC_UTF8 , LR_ENC_SYSTEM_LOCALE , "sEncoding"); //所以这一步还要转 ==0 不要 ==1 0表示字符相等
if (strcmp(lr_eval_string("{sEncoding}") , "注册成功") == ) {
lr_end_transaction("post_json2", LR_PASS); }else{
lr_end_transaction("post_json2", LR_FAIL);
} return ;
}
运行日志如下:
Virtual User Script started at : -- ::
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0. for WINXP; build (Aug ::) [MsgId: MMSG-]
Run Mode: HTML [MsgId: MMSG-]
Run-Time Settings file: "C:\Documents and Settings\test\Local Settings\Temp\noname35\\default.cfg" [MsgId: MMSG-]
Ending action vuser_init.
Running Vuser...
Starting iteration .
Starting action Action.
Action.c(): Registering web_reg_save_param was successful [MsgId: MMSG-]
Action.c(): Notify: Transaction "post_json2" started.
Action.c(): Warning -: The header being added may cause unpredictable results when applied to all ensuing URLs. It is added anyway [MsgId: MWAR-]
Action.c(): web_add_header("Content-type") highest severity level was "warning" [MsgId: MMSG-]
Action.c(): Warning: The string '"userName":"test","password":"1234","gender":1,"phoneNum":"110","email":"beihe@163.com","address":"beijing"' with parameter delimiters is not a parameter.
Action.c(): t=635ms: -byte response headers for "http://localhost:8080/pinter/com/register" (RelFrameId=, Internal ID=)
Action.c(): HTTP/1.1 \r\n
Action.c(): Content-Type: application/json;charset=UTF-\r\n
Action.c(): Transfer-Encoding: chunked\r\n
Action.c(): Date: Sat, Mar :: GMT\r\n
Action.c(): \r\n
Action.c(): t=668ms: -byte chunked response overhead for "http://localhost:8080/pinter/com/register" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): t=671ms: -byte chunked response overhead for "http://localhost:8080/pinter/com/register" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): \r\n
Action.c(): \r\n
Action.c(): t=680ms: -byte chunked response body for "http://localhost:8080/pinter/com/register" (RelFrameId=, Internal ID=)
Action.c(): {"code":"","message":"娉ㄥ唽鎴愬姛","data":null}
Action.c(): Notify: Saving Parameter "msg = 娉ㄥ唽鎴愬姛".
Action.c(): HTML parsing not performed for Content-Type "application/json" ("ParseHtmlContentType" Run-Time Setting is "TEXT"). URL="http://localhost:8080/pinter/com/register" [MsgId: MMSG-]
Action.c(): web_custom_request("post_json") was successful, body bytes, header bytes, chunking overhead bytes [MsgId: MMSG-]
Action.c(): Notify: Parameter Substitution: parameter "msg" = "娉ㄥ唽鎴愬姛"
Action.c(): Notify: Saving Parameter "sEncoding = 注册成功\x00".
Action.c(): Notify: Parameter Substitution: parameter "sEncoding" = "注册成功\x00"
Action.c(): Notify: Transaction "post_json2" ended with "Pass" status (Duration: 0.5955 Wasted Time: 0.4410).
Ending action Action.
Ending iteration .
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
log
服务器返回中文乱码的情况(UTF8编码 -> 转化为 SYSTEM_LOCALE 编码)的更多相关文章
- 【linux】centos7终端中文显示乱码,命令返回中文乱码
centos7终端中文显示乱码,命令返回中文乱码 1.查看服务器编码的命令 1.1 echo $LANG 1.2 locale 1.3 查看终端xshell编码 如果以上的三点依旧保持一致,而依旧乱码 ...
- ajax提交 返回中文乱码问题
接口返回数据相关 使用@ResponseBody后返回NUll 说明:刚把后台运行起来,兴高采烈的测试接口数据,结果无论如何都是返回null, 最终通过各种百度,发现原来是没有引入关键的Jar包. 解 ...
- springmvc返回中文乱码问题
关于springmvc的返回中文乱码的问题,网上可谓是清一色的一样,无外乎就两种,要么在局部类或这方法上解决,类似如下的代码: @GetMapping(value="/error/query ...
- jsp中文乱码六种情况---解决方案
转 jsp中文乱码六种情况---解决方案 2016年10月22日 21:32:55 阅读数:10672 来源:http://blog.csdn.net/lovesummerforever/articl ...
- 解决SpringMVC的@ResponseBody返回中文乱码
SpringMVC的@ResponseBody返回中文乱码的原因是SpringMVC默认处理的字符集是ISO-8859-1,在Spring的org.springframework.http.conve ...
- Springboot @ResponseBody返回中文乱码
最近我在把Spring 项目改造Springboot,遇到一个问题@ResponseBody返回中文乱码,因为response返回的content-type一直是application/json;ch ...
- spring ajax以及页面返回中文乱码问题解决
在spring配置文件中添加 <!--返回中文乱码--> <mvc:annotation-driven > <!-- 消息转换器 --> <mvc:messa ...
- SpringMVC @ResponseBody返回中文乱码
SpringMVC的@ResponseBody返回中文乱码的原因是SpringMVC默认处理的字符集是ISO-8859-1, 在Spring的org.springframework.http.conv ...
- nodejs 写服务器解决中文乱码问题
nodejs 写服务器解决中文乱码问题:https://blog.csdn.net/worldmakewayfordream/article/details/77483423 本文链接:htt ...
随机推荐
- OpenCV 中CV_IMAGE_ELEM 的使用
CV_IMAGE_ELEM 是一个宏函数,基本形式: CV_IMAGE_ELEM(image,elemtype,row,col) 其中,image为指针数组,elemtype为数据的存取类型,row为 ...
- Hibernate一级缓存和三种状态
Hibernate一级缓存又称session缓存,生命周期很短,跟session生命周期相同. 三种状态:1.transient(瞬时态):刚new出来的对象,既不在数据库中,也不在session管理 ...
- 简单几行代码使用百度地图API接口分页获取信息
首发于: 万能助手扩展开发:使用百度地图API接口分页获取信息_电脑计算机编程入门教程自学 http://jianma123.com/viewthread.aardio?threadid=426 使用 ...
- GIT更新一其中一个提交版本
有一小朋友刚才SVN转到GIT,最近老是咨询怎么才svn update -rXXXXX 在git其实也不麻烦,就是git checkout的事情,不管是分支还是TAG,都会有一个HASH版本号 1. ...
- 【usaco】1.1
你的飞碟在这儿Your Ride Is Here(难度:入门难度) 题目链接 题目大意 emmmm 输入两个字符串,问他们每个字母的asco码相乘后字符串是否相等. 思路 一道水题?(雾) 错误代码: ...
- chromium之ScopedNSAutoreleasePool浅析
上代码,看看注释 ScopedNSAutoreleasePool只有Mac系统特有的,也可以理解为OC特有的函数, 其他系统为空实现 // On the Mac, ScopedNSAutorele ...
- excel 开头 结尾,中间 类似 SQL like ab% ,%ab ,%ab%
excel 开头 结尾,中间 类似 SQL like 'ab%' ,'%ab' ,'%ab%' 在R2 单元格 查找 ab开头,ab结尾 =Search("ab",R ...
- vowels_单元音
vowels(美式): 单元音: [i]:需要用劲喊出类似于“yi”的四声,费力咧开嘴,单词eat.need.thief.meet. [?]:卷舌音,单词bird.her.worry.certain. ...
- linux 搭建ss
因为收藏的各种教程被xx,所以决定自己写 第一步.安装ss sudo pip install shadowsocks 第二步.配置IP.端口.密码.加密方式 vi /etc/shadowsocks.j ...
- Java中的File.separator用法
在Windows下的路径分隔符和Linux下的路径分隔符是不一样的,当直接使用绝对路径时,跨平台会暴出“No such file or diretory”的异常. 比如说要在temp目录下建立一个te ...