注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → 编程开发JSP → 文章内容

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

作者:佚名 来源:不详 发布时间:2007-11-30 0:00:07

  对此问题的解决办法之一是写一个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 ;
}
}
}


  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体
关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved