服务器返回中文乱码的情况(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 ...
随机推荐
- VS2017无法打开Razor视图文件
VS2017一直卡顿就在扩展和更新里把没用的插件关闭了.导致后来一直NETCORE的Razor视图文件打不开 查了资料才知道需要依赖 ASP.NET Core Razor Language Servi ...
- 类似QQ的聊天工程
首先建立一个html:<!DOCTYPE html><html lang="en"><head> <meta charset=" ...
- react使用echarts地图实现中国地图大区展示
日常项目中经常会用到百度地图或者echarts图标展示,今天给大家展示的是如何在react开发项目中使用百度echars的地图展示,把中国地图分为东北大区.华东大区.华南大区.华西大区.华中大区以及华 ...
- oracle sqldrl命令与以及ctl文件
具体操作如下: 第一步:先编辑好数据控制文件 xx.ctl,如test.ctl options(skip=1) --跳过第一行(看实际情况) load data infile 'C:\Users\ ...
- 简单的反编译class文件并重新编译的方法
在没有.java源码的情况下,如果想修改一个.class文件.可以通过以下步骤实现: 修改前的class文件: 一.反编译.class文件成.java文件. 1.可以使用Java Decompiler ...
- jQuery动态绑定事件(左右移动)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 集合之WeakHashMap
WeakHashMap 底层数据结构是哈希表结构 依赖于键的数据结构特点 不同于HashMap,该类的键是以弱键的形式存在 当该键成为垃圾对象,会被垃圾回收期空闲的时候回收,那么改键所对应值也会被回收 ...
- 对QP中RTC的理解
1.概念 RTC(Run To Completion)是运行到完成为止的意思.在状态机中,从源状态到目标状态的转换动作要运行到完成. 从字面上来看,这个过程像是不可中断的,但实际并不是,这个过程可以被 ...
- Python学习手册之 Python 之禅、Python 编程规范和函数参数
在上一篇文章中,我们介绍了 Python 的正则表达式使用示例,现在我们介绍 Python 之禅. Python 编程规范和函数参数.查看上一篇文章请点击:https://www.cnblogs.co ...
- ISAP学习笔记
学完了ISAP,感觉心情舒畅,毕竟ISAP比Dinic好一点. 说到底ISAP其实是Dinic(不熟悉Dinic的人去我的博客找猴子课堂----最大流与最小割(看看思想),已经置顶)优化版,熟悉的人知 ...