服务器返回中文乱码的情况(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 ...
随机推荐
- VS 2017 + EF6 + MySQL5.7 建立实体模型闪退问题
具体环境是:VS2017 ..NET Framework 4.6 .MySql.Data.Entity 6.9.12 在这个环境下总是不成功,具体是在这一步闪退,也不报错: 在点击“下一步”后,没有进 ...
- hashMap 和 linkedHashMap 的区别和联系
直接举例说明. 运行如下例子程序 mport java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; ...
- ATM购物作业
一. 基本需求 模拟实现一个ATM + 购物商城程序 额度 15000或自定义 实现购物商城,买东西加入 购物车,调用信用卡接口结账 可以提现,手续费5% 支持多账户登录 支持账户间转账 记录日常消费 ...
- 『Python基础-10』字典
# 『Python基础-10』字典 目录: 1.字典基本概念 2.字典键(key)的特性 3.字典的创建 4-7.字典的增删改查 8.遍历字典 1. 字典的基本概念 字典一种key - value 的 ...
- 实验吧web加了料的报错注入
知识点: SQL注入中用到的Concat函数详解 http://www.sohu.com/a/219966085_689961 http分割注入 直接根据提示,提交post请求的用户名和密码 结 ...
- 最小生成树——Kruscal(克鲁斯卡尔算法)
一.核心思想 将输入的数据由小到大进行排序,再使用并查集算法(传送门)将每个点连接起来,同时求和. 个人认为这个算法比较偏向暴力,有些题可能会超时. 二.例题 洛谷-P3366 题目地址:ht ...
- Codeforces Round #482 (Div. 2) :B - Treasure Hunt
题目链接:http://codeforces.com/contest/979/problem/B 解题心得: 这个题题意就是三个人玩游戏,每个人都有一个相同长度的字符串,一共有n轮游戏,每一轮三个人必 ...
- 使用JAX-WS(JWS)发布WebService(一)
JAX-WS概述: 通过Main发布一个简单WebService: JAX-WS(Java API for XML Web Services)规范是一组XML web services的JAVA AP ...
- 打开所有https网页都提示证书错误
最近安装了网上下载的ghost系统,可是不管是win7还是xp,打开所有的https网站都提示证书错误.想想现在打击盗版系统的力度不断增加,以前做的比较好的盗版系统网站都已经不再做系统了,现在下载的g ...
- Android Studio 引入 Git 并提交代码
File -> Settings -> Version Control -> Git -> Path to Git executable -> 选择本地 Git 可执行文 ...