随笔 - 100  文章 - 50  trackbacks - 0
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(3)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

我收藏的一些文章!

搜索

  •  

最新评论

阅读排行榜

评论排行榜


public static String UnicodeToChinese(String s) {
try {
if (s == null || s.equals(""))
return "";
String newstring = null;
newstring = new String(s.getBytes("ISO8859_1"), "gb2312");
return newstring;
} catch (UnsupportedEncodingException e) {
return s;
}
}

public static String ChineseToUnicode(String s) {
try {
if (s == null || s.equals(""))
return "";
String newstring = null;
newstring = new String(s.getBytes("gb2312"), "ISO8859_1");
return newstring;
} catch (UnsupportedEncodingException e) {
return s;
}
}  
写进数据库时用ChineseToUnicode()方法进行编码,读出来的时候用UnicodeToChinese()方法进行解码既可
 

posted on 2006-08-11 17:01 fly 阅读(316) 评论(0)  编辑  收藏 所属分类: jsp学习

只有注册用户登录后才能发表评论。


网站导航: