我在oracle8i中,在数据库和页面显示的都是乱码?

显示的,都是乱码,我把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;
}
}

参照Oracle+jsp的中文解决办法吧

从cvs里co出来后要用GBK编码来compile

1.要保证数据库中的中文不是乱码。
2.然后在你的jsp中加
<%@ page contentType="text/html;charset=gb2312"%>
试试。


<%@ page contentType="text/html;charset=gb2312"%>

我也遇到同样的问题



参照Oracle+jsp的中文解决办法吧

BANG 这个帖子,论坛搜索不到,在哪里啊!!!

楼主有没有解决掉这个问题?解决了告诉一声:)谢谢啦

中文问题比较复杂,有时不是 ISO,GBK 两个简单的转转就能用的。
像我以前做 Linux 下支持中文文件名的 Disk 管理器时,
就吃了不少苦头。

具体问题具体分析,乱转是没有用的!!!
首先你要说说你数据库的编码,
然后,你的 JSP 使用的编码,有没有像 PetStore 1.3.1 一样使用 EncodingFilter?...

有人建议所有的系统都使用统一编码,
数据库里存的是 UTF-8,显示时也使用 UTF-8,就不会有任何问题了。
当然,这对于大多数情况下是够用了,但是一旦遇到不支持 UTF-8 编码的系统时就会出现问题。

对于这样的特殊情况,就需要特殊处理。

jive论坛哪部分的代码是和编码有关的?怎么我自己写的程序从数据库里面提数据没问题?

1.首先用Sqlplus看一下数据的中文显示是否正确,如果是????,那么说明Oracle客户端和服务器之间的字符集配置不一致。
Oracle的客户端和服务器字符集必须配置一致,假设服务器是
American_America.US7ASCII
那么客户端也必须是
American_America.US7ASCII
这样即使数据库中有中文,客户端也可以正常显示。
或者客户端服务器全都是
Simplified Chinese_China.GBK(GB2312)
具体写法记不清了。
2.其次再用Java程序试一下,有可能不用转码数据即可正常显示。

一定注意Oracle服务器和Tomcat服务器上的字符集必须设置相同。

Tomcat服务器上的字符集怎么配置?

在Tomcat服务器上安装Oracle Client,测试Sqlplus查询的结果是否为乱码。
配置该Client的字符集,跟普通的Oracle客户端的字符集配置相同。
如果是Windows的话,应该在注册表里配置,详细步骤记不清了。

Oracle客户端字符集在Windows注册表里的设置;

修改/HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/HOME0/NLS_LANG键值

中文:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
英文:AMERICAN_AMERICA.WE8ISO8859P1