Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WxPayServiceImpl的post方法,编码转换存在BUG #225

Closed
izee opened this issue May 9, 2017 · 9 comments
Closed

WxPayServiceImpl的post方法,编码转换存在BUG #225

izee opened this issue May 9, 2017 · 9 comments

Comments

@izee
Copy link

izee commented May 9, 2017

try {
  responseString = new String(response.bodyText().getBytes(CharEncoding.ISO_8859_1), CharEncoding.UTF_8);
} catch (UnsupportedEncodingException e) {
  e.printStackTrace();
}

服务器返回值的编码并非全是ISO_8859_1,建议更换为:EntityUtils.toString(response.getEntity(), Consts.UTF_8);

@izee
Copy link
Author

izee commented May 9, 2017

试了下在线编辑,不知道对不对
#226

@binarywang
Copy link
Owner

能否详细说下,是哪些接口可能会有问题?而且你测试过了没有,能否保证你的代码对所有接口都是可行的?

@izee
Copy link
Author

izee commented May 9, 2017

@binarywang 服务器返回错误信息时,中文全是乱码,说明response返回的不是ISO_8859_1编码,EntityUtils.toString方法,会优先判断response指定的编码

@binarywang
Copy link
Owner

我知道, 但EntityUtils 这个类是httpclient的,跟我们项目里使用的jodd-http不是同一个东西,无法使用。

@binarywang
Copy link
Owner

另外,我刚跑了下单元测试里的代码,没有乱码现象发生,所以我不确定你所说的乱码是怎么回事

@binarywang
Copy link
Owner

没有进一步的信息可以排查,暂时关闭

@binarywang
Copy link
Owner

我又仔细测试了下,有的接口会乱码,有的不会,不能一概处理,需要仔细区分下

@binarywang binarywang reopened this Jun 18, 2017
@binarywang
Copy link
Owner

目前观察到的情况很复杂,同样的接口在有正确响应情况下的编码与出现错误的响应编码可能还不一样,而不同的接口情况还可能不一样。

@binarywang
Copy link
Owner

已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants