<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
对此问题的解决办法之一是写一个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 ;
}
}
}
参数传递过程中的中文问题
最新推荐文章于 2020-05-21 13:32:06 发布
本文介绍了一种通过编写Java Bean来实现从ISO-8859-1字符集到GBK字符集转换的方法。该Bean提供了convert方法,可以将输入字符串从ISO-8859-1编码转换为GBK编码,解决了字符集转换的问题。
3062

被折叠的 条评论
为什么被折叠?



