现在在做一个涉及到藏文的页站 我数据库操作系统用的是sql server2000(因为支持藏GB18030)可是在jsp页面上输入藏文 然后插入表的过程中 遇到转码问题在数据库中显示的是乱码 还有我在表中有藏文 然后查出来显示的时候 也是乱码 各位大侠能不能给我弄个办法解决下啊我自己曾试过的方法 用过滤器 在页面上用<meta http-equiv="Content-Type" content="text/html; charset=GB18030" /> 还有用过转码 new String(.getByts("")."") 分数可加!
import java.io.*;public class EncodingTest { /**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
File file=new File("C:/Users/zhoubols/Documents/1.txt");
if(!file.exists())
{
System.out.println("文件不存在!");
return;
}
FileInputStream read=new FileInputStream(file);
InputStreamReader reader=new InputStreamReader(read);
BufferedReader buff=new BufferedReader(reader);
for(String str=buff.readLine();str!=null;str=buff.readLine())
{
//System.out.println(str);
str=new String(str.getBytes(),"UTF-8");
System.out.println(str);
}
}}
其中1.txt是一个含有藏文的文本文件(vista下的记事本,保存的编码是UTF-8)。结果显示的也是乱码