不同系统间中文乱码问题

flush_520 2009-02-03 10:00:11
win上面的weblogic发送报文---unix上接收中文乱码
代码如下:

response.setContentType("text/xml;charset=UTF-8");

//ServletOutputStream sops = response.getOutputStream();//这样也是
PrintWriter sops= response.getWriter();
//中文转换utf-8
try {
responseData =URLDecoder.decode(responseData, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
byte[] outdata = responseData.getBytes("UTF-8");
responseData=new String(outdata,"utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sops.print(responseData);

responseData是string类型 在本地是

<RespCode>01</RespCode>
<RespDesc>用户不存在</RespDesc>


而在unix接收就为
<RespCode>01</RespCode>
<RespDesc>??¢??·?§ˉ??????????¤?</RespDesc>


高手们看下该如果搞
...全文
117 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
flush_520 2009-02-03
  • 打赏
  • 举报
回复
那边说OK了就结贴哦 多谢各位
flush_520 2009-02-03
  • 打赏
  • 举报
回复
+++%3CAnswerCode%3E00010002%3C%2FAnswerCode%3E%0A++++%3CDesc%3E%E7%94%A8%E6%88%B7%E4%B8%8D%E5%AD%98%E5%9C%A8%28%E9%9D%9E%E8%81%94%E9%80%9A%E6%9C%89%E6%95%88%E7%94%A8%E6%88%B7%29%3C%2FDesc%

本地测试是这样的东西 把它经过urldecode转换为utf-8可以正常,但这个应该不行
chen2319 2009-02-03
  • 打赏
  • 举报
回复
URLEncoder.encode(xxxx,"UTF-8")
flush_520 2009-02-03
  • 打赏
  • 举报
回复
先用楼上的试下
HinanaiTenshi 2009-02-03
  • 打赏
  • 举报
回复
编码用URLEncoder.encode(xxxx,"UTF-8")吧,decode似乎是解码.
HinanaiTenshi 2009-02-03
  • 打赏
  • 举报
回复
尝试在发送之前先按uft-8编码吧
flush_520 2009-02-03
  • 打赏
  • 举报
回复
unix上是用utf-8接收的 那边不是我做,是统一的接口,其他一部分人做的那边接收不乱码,而我的乱码
kukufly 2009-02-03
  • 打赏
  • 举报
回复
xue xi le
海诗美妆 2009-02-03
  • 打赏
  • 举报
回复
在unix下用Firefox以UTF-8打开xml看看。
vi的话需要设定编码。

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧