是因为中文字段的问题吗? 当然不对了,应该是 newstring=new String(s.getBytes("gb2312"),"ISO8859_1");这种形式。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以先取得这个字符串,然后再转码:sTHDR = new String(theDataModel.GetItemBytes(2));sTHDR = new String(sTHDR.getBytes("ISO8859_1"),"GBK"); TO:namowen可我的变量sTHDR是String,我用上面的sTHDR = theDataModel.GetItemString(2);取得这个字符串在转码可以吗? 严格的讲应该是这样的,先判断theDataModel.GetItemBytes(2)是否为nullString a=theDataModel.GetItemBytes(2);String b="";if (a==null){a="";}else{b=new String(a.getBytes("ISO8859_1"),"gb2312");}这样就彻底解决了中文问题了,我说的是针对你的这个问题。 应该是所取得字段类型,不可以用getBytes那个出问题的字段的类型是什么? TO:littlecongvarchar用theDataModel.GetItemString(2);取得是乱码应该怎么转换呢? 搞定给分……哦,在请教我把varchar型的数据用getBytes()取得行不行,取得后的数据是String型还是Byte型呢?我上面的问题使用sTHDR = new String(theDataModel.GetItemString(2));取得数据在象namowe说的:sTHDR = new String(sTHDR.getBytes("ISO8859_1"),"GBK");转码一下,为了保险加入了wjmmml的判断。:) ------哦,在请教我把varchar型的数据用getBytes()取得行不行,取得后的数据是String型还是Byte型呢?varchar类型用getBytes来取出系统肯定出错,会提示字段类型出错,为什么字符型字段不用getString来提取数据? 我给你一个中文处理的方法,你用用看public String getStr(String str)//中文处理{ try { String temp_p=str; byte[] temp_t=temp_p.getBytes("ISO8859-1"); String temp=new String(temp_t); return temp; } catch(Exception e) { e.printStackTrace() ; } return "null";} java jxl 实现导出Excel另存为 java 保持目录结构复制文件 如何给系统的类增加成员方法,比如给String增加一个toLocalString()的方法 ??? 数组上面遇到的问题 这段关于多态性的代码怎么理解? java web start 发布带access的swing程序 关于计算一个月有多少天的问题?在线等!谢谢! 在jb2006中引入了jbcl-src包后为什么XYLayout类还是没法用???? 哪里有Jcreator下载,在线等待。 java -jar hello.jar 不能执行为什么?? 关于邮件服务器的问题 那里可以下载企业版的Jbuilder7!
sTHDR = new String(theDataModel.GetItemBytes(2));
sTHDR = new String(sTHDR.getBytes("ISO8859_1"),"GBK");
可我的变量sTHDR是String,我用上面的sTHDR = theDataModel.GetItemString(2);取得这个字符串在转码可以吗?
String a=theDataModel.GetItemBytes(2);
String b="";
if (a==null){
a="";}else{
b=new String(a.getBytes("ISO8859_1"),"gb2312");}
这样就彻底解决了中文问题了,我说的是针对你的这个问题。
那个出问题的字段的类型是什么?
varchar
用theDataModel.GetItemString(2);取得是乱码应该怎么转换呢?
哦,在请教我把varchar型的数据用getBytes()取得行不行,取得后的数据是String型还是Byte型呢?
我上面的问题使用sTHDR = new String(theDataModel.GetItemString(2));取得数据在象namowe说的:
sTHDR = new String(sTHDR.getBytes("ISO8859_1"),"GBK");转码一下,为了保险加入了wjmmml的判断。:)
varchar类型用getBytes来取出系统肯定出错,会提示字段类型出错,为什么字符型字段不用getString来提取数据?
public String getStr(String str)//中文处理
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
e.printStackTrace() ;
}
return "null";
}