字符转换的梦魇,谁来唤醒我 试试x=new String(s.getBytes("ISO8859_1"),"GBK"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 x=new String(s.getBytes(),"GBK"); s=new String(s.getBytes("ISO-8859-1"),"gb2312"); 各位请先run一下这个:public class test { public static void main(String[] args) { test t=new test(); t.trans(); } public void log(String s) { System.out.println(s); } private void trans() { String[] encode={"UTF8","GBK","gb2312","8859_1"}; String s,x; s="鍒犻櫎"; try { for (int i=0;i<encode.length;i++) { for (int k=0;k<encode.length;k++) { x=new String(s.getBytes(encode[i]),encode[k]); log(encode[i]+"\t>\t"+encode[k]+"\t="+x); } } }catch(Exception e){ e.printStackTrace(System.out); } }} s=new String(s.getBytes("ISO-8859-1"),"gb2312");或者是s=new String(s.getBytes("gb2312"),"ISO-8859-1");两个换着用,肯定好使,我试过!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!谢谢大家,但问题仍未解决请先 run 一下 回复4 的例程。request.getProperty(key) 的返回值encoding格式似乎是 UTF8,用get方法可以看到是三字节编码!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 首先确定你的web server编码和jdbc编码。这里,我用resin,oracle的class12.jar如果你想得到unicode十进制编码,在jsp中作如下设置:<%@ page contentType="text/html; charset=iso-8859-1"%>如果希望得到和系统编码一样的字串,不要设定上面这行。只要设定<meta http-equiv="Content-Type" content="text/html; charset=GBK">就可以。欢迎交流。[email protected] sss !!! [===] /|\ 有请高手降临...(我想问题关键是 GBK -> UTF8 转换不完全。) x =new String(s.getBytes("ISO8859_1"),"GBK") 怎么把word格式转换为PDF格式 大家来帮我看看这个下标越界的问题,搞的有点累 php jsp 谁来证明"大花猫"是错误的? 如何取得浮点数的整数部分和小数部分? 关于split()的一个比较棘手的问题 怎么判断图片加载成功? 紧急求助:菜单的使用 怎样把String字符串转换成byte[]数组 吐血散分!!!!请教学习Java的方法,大家都来说说。 请问谁有JAVA编码规则?能否给小弟一份?先谢了! 请众大侠为小弟指一条学习Java的明路........
public class test {
public static void main(String[] args) {
test t=new test();
t.trans();
}
public void log(String s) {
System.out.println(s);
}
private void trans() {
String[] encode={"UTF8","GBK","gb2312","8859_1"};
String s,x;
s="鍒犻櫎";
try {
for (int i=0;i<encode.length;i++) {
for (int k=0;k<encode.length;k++) {
x=new String(s.getBytes(encode[i]),encode[k]);
log(encode[i]+"\t>\t"+encode[k]+"\t="+x);
}
}
}catch(Exception e){ e.printStackTrace(System.out); }
}
}
或者是s=new String(s.getBytes("gb2312"),"ISO-8859-1");
两个换着用,肯定好使,我试过!!
请先 run 一下 回复4 的例程。
request.getProperty(key) 的返回值encoding格式
似乎是 UTF8,用get方法可以看到是三字节编码!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
这里,我用resin,oracle的class12.jar
如果你想得到unicode十进制编码,在jsp
中作如下设置:
<%@ page contentType="text/html; charset=iso-8859-1"%>
如果希望得到和系统编码一样的字串,不要设定上面这行。
只要设定<meta http-equiv="Content-Type" content="text/html; charset=GBK">就可以。欢迎交流。
[email protected]
!!!
[===]
/|\
有请高手降临...
(我想问题关键是 GBK -> UTF8 转换不完全。)