服务器乱码 转换使用如下方法

入惨{“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 编码)的更多相关文章

  1. 【linux】centos7终端中文显示乱码,命令返回中文乱码

    centos7终端中文显示乱码,命令返回中文乱码 1.查看服务器编码的命令 1.1 echo $LANG 1.2 locale 1.3 查看终端xshell编码 如果以上的三点依旧保持一致,而依旧乱码 ...

  2. ajax提交 返回中文乱码问题

    接口返回数据相关 使用@ResponseBody后返回NUll 说明:刚把后台运行起来,兴高采烈的测试接口数据,结果无论如何都是返回null, 最终通过各种百度,发现原来是没有引入关键的Jar包. 解 ...

  3. springmvc返回中文乱码问题

    关于springmvc的返回中文乱码的问题,网上可谓是清一色的一样,无外乎就两种,要么在局部类或这方法上解决,类似如下的代码: @GetMapping(value="/error/query ...

  4. jsp中文乱码六种情况---解决方案

    转 jsp中文乱码六种情况---解决方案 2016年10月22日 21:32:55 阅读数:10672 来源:http://blog.csdn.net/lovesummerforever/articl ...

  5. 解决SpringMVC的@ResponseBody返回中文乱码

    SpringMVC的@ResponseBody返回中文乱码的原因是SpringMVC默认处理的字符集是ISO-8859-1,在Spring的org.springframework.http.conve ...

  6. Springboot @ResponseBody返回中文乱码

    最近我在把Spring 项目改造Springboot,遇到一个问题@ResponseBody返回中文乱码,因为response返回的content-type一直是application/json;ch ...

  7. spring ajax以及页面返回中文乱码问题解决

    在spring配置文件中添加 <!--返回中文乱码--> <mvc:annotation-driven > <!-- 消息转换器 --> <mvc:messa ...

  8. SpringMVC @ResponseBody返回中文乱码

    SpringMVC的@ResponseBody返回中文乱码的原因是SpringMVC默认处理的字符集是ISO-8859-1, 在Spring的org.springframework.http.conv ...

  9. nodejs 写服务器解决中文乱码问题

    nodejs 写服务器解决中文乱码问题:https://blog.csdn.net/worldmakewayfordream/article/details/77483423     本文链接:htt ...

随机推荐

  1. RabbitMQ + topic发送消息+python

    接口使用两个queue监听信息,且有两个测试环境,所以需要向mq中发送测试数据: python使用pika包:Pika is a RabbitMQ (AMQP-0-9-1) client librar ...

  2. mysql错误errno:121

    121错误是因为外键名重复.在同一个库中外键是不允许与其他外键重名的. 遇到这个错误请给你定义的外键换唯一无重复的名字. 同时查阅到外键也有可能导致150错误. Can't create table ...

  3. php开发微信图灵机器人

    本着开源为原则,为这个世界更美好作出一份共享,我就给大家做个指路人,如果实用,记得给提供开源的朋友一些鼓励. 简单介绍一下实现思路,使用swoole扩展接管php运行,由于swoole只能在类UNIX ...

  4. Python豆瓣源

    pip install -i https://pypi.doubanio.com/simple/ xxxx

  5. axios api封装

    import axios from 'axios'; import qs from 'qs'; const host = 'url' axios.defaults.baseURL = host; // ...

  6. obfuscator-llvm Xcode集成配置

    一.简介 obfuscator-llvm 是一个开源的代码混淆编译器,能够使编译出来的文件添加垃圾代码和各种跳转流程,给逆向分析者增加难度. 二.编译 (1) 下载 目前最新版的是4.0的,下载地址是 ...

  7. python爬虫学习笔记(1)

    一.请求一个网页内容打印 爬取某个网页: from urllib import request # 需要爬取的网页 url = "https://mbd.baidu.com/newspage ...

  8. sourcetree .git 强制忽略指定文件不提交

    在公司写项目,大部分都会用到 svn 或 git 提交代码到服务器.我们公司用的GIT,每个程序员有自己的独立分支,各写各的代码互不冲突,最终合并到主分支再解决相同代码冲突问题.这时候会遇到一些配置文 ...

  9. Java学习笔记二十六:Java多态中的引用类型转换

    Java多态中的引用类型转换 引用类型转换: 1.向上类型转换(隐式/自动类型转换),是小类型到大类型的转换: 2.向下类型转换(强制类型转换),是大类型到小类型的转换: 3.instanceof运算 ...

  10. LVS那些事

    1998年,章文嵩博士成立了Linux Virtual Server的自由软件项目,进行Linux服务器集群的开发工作. 他的目标是:使用集群技术和Linux操作系统实现一个高性能.高可用的服务器,它 ...