参数传递过程中的中文问题

时间:2010-01-19 08:57:05   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:named charset, storing the result into a new byte array.*/ byte[] bytesStr=str.getBytes( "ISO-8859-1" ) ; /*Constructs a new String by decoding the specified array of bytes using the specified charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array. */ return new String( by...
  正文:

对此问题的解决办法之一是写一个bean,好处是可重用。 public class ISOtoGBK { public static String convert( String str ) { if (str.trim()=="") { return null; } try { /*Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array.*/ byte[] bytesStr=str.getBytes( "ISO-8859-1" ) ; /*Constructs a new String by decoding the specified array of bytes using the specified charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array. */ return new String( bytesStr, "GBK" ) ; } catch( Exception ex ) { return str ; } } }


来源:http://www.002pc.com/master/College/Programming/JSP/12032.html

收藏到:

关于《参数传递过程中的中文问题》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='85' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='85' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td