日期:2014-05-19  浏览次数:20921 次

数据流 转string乱码
8月2日计算 变成 “8??2日计??”


byte [] b=XX;//这个没问题
String x = new String(b);//结果像上面有的乱了

------解决方案--------------------
加上编码试试
String x = new String(b, "utf-8");
String x1 = new String(b, "gbk");
------解决方案--------------------
探讨
加上编码试试
String x = new String(b, "utf-8");
String x1 = new String(b, "gbk");

------解决方案--------------------
DataInputStream试试
------解决方案--------------------
String x = new String(b, "UTF-8");

String x1 = new String(b, "ISO-8859-1");

String x2 = new String(b, "gb2312");
------解决方案--------------------
同求解决方法
------解决方案--------------------
探讨

引用:

加上编码试试
String x = new String(b, "utf-8");
String x1 = new String(b, "gbk");

哎 没有用哦

------解决方案--------------------
char [] b=XX;
String x = new String(b);

试试
------解决方案--------------------
这得看你这个“8月2号”本身的编码,然后转成相应的编码。

比如从前端传过来,是ISO-8895-1 
byte[] b=xxx.getBytes("ISO-8859-1");
String o=new string(b,"UTF-8")


------解决方案--------------------
byte [] b=xx.getBytes();
String x = new String(b);
这样就问题了
------解决方案--------------------
晕,是没问题
------解决方案--------------------
可能是你使用了多种编码方式,将程序中所有编码都统一,然后在试试。