BBS水木清华站∶精华区
发信人: yanbo (heenji), 信区: Java
标 题: Re: JDBC从数据库中取的中文全是???,why? (转载)
发信站: BBS 水木清华站 (Sat May 6 16:06:03 2000)
多谢了,不过我试着用这个方法不能成功(在JSP)中,最后用
<%@ page contentType="text/html;charset=gb2312" %>
就可以了
【 在 FrankCH (终有绿叶衬) 的大作中提到: 】
∶ 这个是我的用于数据库取出中文乱码和网络取出中文乱码的处理函数
∶ 其实精华区也有类似的东西。
∶ 入参是有问题的String,出参是解决了的String
∶ String parseChinese(String in)
∶ {
∶ String s = null;
∶ byte temp [];
∶ if (in == null)
∶ {
∶ System.out.println("Warn:Chinese null founded!");
∶ return new String("");
∶ }
∶ try
∶ {
∶ temp=in.getBytes("iso-8859-1");
∶ s = new String(temp);
∶ }
∶ catch(UnsupportedEncodingException e)
∶ {
∶ System.out.println (e.toString());
∶ }
∶ return s;
∶ }
--
※ 来源:·BBS 水木清华站 smth.org·[FROM: 202.112.92.6]
BBS水木清华站∶精华区