急,急,急,在JAVA中如何把UTF-16BE编码转化为GB2312编码??? 试试先转换成Unicode,再转成你需要的字符编码。getByte(). 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static String getWriteStr(String str) { try { String temp_p = str; byte[] temp_t = temp_p.getBytes("GBK"); String unicode = new String(temp_t,"ISO8859-1"); return unicode; } catch(Exception e) { return "null"; } } public static String toGBK(String strValue){ //将strValue编码转换为GBK,防止乱码。 try{ byte buf[]=strValue.getBytes("ISO8859-1"); String string=new String(buf,"GBK"); String str=string; return str; }catch(Exception ex){ String eStr=null; return eStr; } } public static String toISO8859(String strValue){ //将strValue编码转换为GBK,防止乱码。 try{ byte buf[]=strValue.getBytes("GBK"); String string=new String(buf,"ISO8859-1"); String str=string; return str; }catch(Exception ex){ String eStr=null; return eStr; } } String tmp = new String(strUnicode.getBytes("UTF-16BE"), "GB2312");其中,tmp就是GB2312的字符串。strUnicode是转换前的字符串。 strut2转换器问题 strut2如何让没有后缀的请求不经过struts2框架的处理? 日志文件插入String问题 弱的一下,不用jsp界面,而直接放servlet在配置文件中的映射,doget()是如何被调用的? 请教关于Jdk1.6+tomcat5 ,jsp页面utf-8乱码问题,谢谢 J2EE安装与程序步署问题 一个冲动的想法(做一个数据库),大家帮帮忙,,,, 实体bean问题100分(高手请进) struts的forward问题,还是没有解决 一个list解析问题 Hibernate 中检索调试有啥好办法 救命啦!jsp+tomcat+sql server运行问题!
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("GBK");
String unicode = new String(temp_t,"ISO8859-1");
return unicode;
}
catch(Exception e) {
return "null";
}
}
//将strValue编码转换为GBK,防止乱码。
try{
byte buf[]=strValue.getBytes("ISO8859-1");
String string=new String(buf,"GBK");
String str=string;
return str;
}catch(Exception ex){
String eStr=null;
return eStr;
}
}
public static String toISO8859(String strValue){
//将strValue编码转换为GBK,防止乱码。
try{
byte buf[]=strValue.getBytes("GBK");
String string=new String(buf,"ISO8859-1");
String str=string;
return str;
}catch(Exception ex){
String eStr=null;
return eStr;
}
}
String tmp = new String(strUnicode.getBytes("UTF-16BE"), "GB2312");其中,tmp就是GB2312的字符串。strUnicode是转换前的字符串。