当前位置:网站首页>jmeter -- response中文乱码处理
jmeter -- response中文乱码处理
2022-07-26 21:18:00 【zyanwei2018】
- 方法一:修改配置
vim jmeter.properties
# 修改1094行ISO-8859-1为UTF-8
# sampleresult.default.encoding=ISO-8859-1
sampleresult.default.encoding=UTF-8
- 方法二:后置处理器
- 线程组–后置处理器–BeanShell后置处理器,添加代码如下:
String s2 = new String(prev.getResponseData(), "UTF-8");
//---------------一下步骤为转码过程---------------
char aChar;
int len = s2.length();
StringBuffer outBuffer = new StringBuffer(len);
for (int x = 0; x < len;)
{
aChar = s2.charAt(x++);
if (aChar == '\\') {
aChar = s2.charAt(x++);
if (aChar == 'u') {
int
value = 0;
for (int i = 0;
i < 4;
i++
)
{
aChar = s2.charAt(x++);
switch (aChar) {
case'0':
case'1':
case'2':
case'3':
case'4':
case'5':
case'6':
case'7':
case'8':
case'9':
value = (value << 4) + aChar - '0';
break;
case'a':
case'b':
case'c':
case'd':
case'e':
case'f':
value = (value << 4) + 10 + aChar - 'a';
break;
case'A':
case'B':
case'C':
case'D':
case'E':
case'F':
value = (value << 4) + 10 + aChar - 'A';
break;
default:
throw new IllegalArgumentException(
"Malformed \\uxxxx encoding.");
}
}
outBuffer.append((char)
value
)
;
} else {
if (aChar == 't')
aChar = '\t';
else if (aChar == 'r')
aChar = '\r';
else if (aChar == 'n')
aChar = '\n';
else if (aChar == 'f')
aChar = '\f';
outBuffer.append(aChar);
}
} else
outBuffer.append(aChar);
}
//-----------------以上内容为转码过程---------------------------
//将转成中文的响应结果在查看结果树中显示
prev.setResponseData(outBuffer.toString());
边栏推荐
- Try new functions | decrypt Doris complex data type array
- [audio and video] ijkplayer player parameter description document
- 正规方程法(Normal Equation)原理以及与梯度下降法的区别
- ZABBIX calls API retrieval method
- A new technical director asked me to do an IP territorial function~
- Pytoch squeeze() unsqueeze() usage
- Altium Designer 22 中文字符乱码
- unity 获取网络时间
- Matlab draws short-term average amplitude spectrum
- Circular progress bar animation based on cashapelayer and Bezier curve
猜你喜欢
随机推荐
cmake编译obs-studio-27.2.0
也谈数据治理
45. Instance segmented labelme dataset to coco dataset and coco dataset to labelme dataset
In depth analysis of the source code, why is the string class immutable? (hit me before you understand)
Pytoch uses RNN model to build person name classifier
matlab 画短时平均幅度谱
吃透负载均衡
[RequireComponent(typeof(....))]
带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?
flask 源码启动阶段
Altium Designer 22 中文字符乱码
现货黄金操作指南与建议(上)
JDBC operation and entry case of MySQL
Leetcode exercise - Sword finger offer II 005. maximum product of word length
Pytorch torch.add() torch.add_() 用法
What to do if the browser home page is tampered with, and how to recover if the home page is tampered with
VB.net Chart1的处理
月薪5万的朋友告诉我,你只是在打杂
Triangular wave spectrum of MATLAB excitation model
一篇让小百彻底搞懂性能调优









