import java.io.UnsupportedEncodingException;public class CodeConverse {
public CodeConverse() {
super();
}public static String toGB(String s)
{
String str = s;
if(s == null)
return null;
try
{
str = new String(s.getBytes("ISO8859-1"), "GB2312");
}
catch(UnsupportedEncodingException ue)
{
System.err.println("UnsupportedEncodingException in DBUtil:toGB()");
}
return str; }
public static String toUnicode(String s)
throws UnsupportedEncodingException
{
if(s == null)
return null;
else
return new String(s.getBytes("GB2312"), "ISO8859-1");
}}调用上面的方法,把你的中文字符串转码。
public CodeConverse() {
super();
}public static String toGB(String s)
{
String str = s;
if(s == null)
return null;
try
{
str = new String(s.getBytes("ISO8859-1"), "GB2312");
}
catch(UnsupportedEncodingException ue)
{
System.err.println("UnsupportedEncodingException in DBUtil:toGB()");
}
return str; }
public static String toUnicode(String s)
throws UnsupportedEncodingException
{
if(s == null)
return null;
else
return new String(s.getBytes("GB2312"), "ISO8859-1");
}}调用上面的方法,把你的中文字符串转码。
<%@ page contentType="text/html;charset=GBK" %><%
response.setContentType("text/html;charset=GBK");
request.setCharacterEncoding("GBK");
%>
<META http-equiv=Content-Type content="text/html; charset=GBK">快快给分啊~~