显示的,都是乱码,我把header,改成GBK,但是也不行,我自己写了一个,但是,和它原来的也有冲突,不知道,要怎么设置,才能让它正确的显示中文?我的机器是2000 server,jdk1.4,tomcat 4.0,下面是我的转换代码的,源代码:请版主帮忙~
package com.jivesoftware.forum.util;
public final class EncodeFactory {
private EncodeFactory() {
}
public static String ISO2GBK(String string) {
String returnValue = "";
try {
if (string != null) {
returnValue = new String(string.getBytes("iso-8859-1"), "GBK");
}
}
catch (Exception e) {
}
return returnValue;
}
public static String GBK2ISO(String string) {
String returnValue = "";
try {
if (string != null) {
returnValue = new String(string.getBytes("GBK"), "iso-8859-1");
}
}
catch (Exception e) {
}
return returnValue;
}
public static String GB2ISO(String string) {
String returnValue = "";
try {
if (string != null) {
returnValue = new String(string.getBytes("GB2312"), "iso-8859-1");
}
}
catch (Exception e) {
}
return returnValue;
}
public static String ISO2GB(String string) {
String returnValue = "";
try {
if (string != null) {
returnValue = new String(string.getBytes("iso-8859-1"), "GB2312");
}
}
catch (Exception e) {
}
return returnValue;
}
public static String Encode(String string, String fromEncode, String toEncode) {
String returnValue = "";
try {
if (string != null) {
returnValue = new String(string.getBytes(fromEncode), toEncode);
}
}
catch (Exception e) {
}
return returnValue;
}
/**
* 可把中文转化为unicode
*/
public static String native2unicode(String string) {
String returnValue = "";
try {
if (string != null) {
returnValue = java.net.URLEncoder.encode(string);
}
}
catch (Exception e) {
}
return returnValue;
}
/**
* 把unicode转化为中文
*/
public static String unicode2native(String string) {
String returnValue = "";
try {
if (string != null) {
returnValue = java.net.URLDecoder.decode(string);
}
}
catch (Exception e) {
}
return returnValue;
}
}