我在oracle8i中,在資料庫和頁面顯示的都是亂碼?

wdx發表於2002-09-23
顯示的,都是亂碼,我把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;
}
}

相關文章