高分求救 我在UNIX系统上 读取文件中文乱码问题
我在UNIX系统上 读取文件中文乱码问题 问题点数:100、回复次数:5Top
1 楼zealVampire(白鹤泉)回复于 2006-03-13 20:19:04 得分 50
UNIX默认的本地机编码是GBK之类的?
如果你的程序再windows下没乱码 就考虑下是不是环境问题 否则就看看你代码是否有问题是否需要转码Top
2 楼aliang_2008(随风翱翔)回复于 2006-03-13 20:41:54 得分 0
我用String enc = System.getProperty("file.encoding");
System.out.println("===="+enc);
在服务器(unix)输出后 是 ISO8859-1
我本地(windows 操作系统)是 GBK
不知道怎样才能解决Top
3 楼ywb1973(谁)(★☆◎☆★)回复于 2006-03-13 20:56:00 得分 50
转码不就可以了?
Unix-->Win
String win=new String(unix.getBytes("ISO8859-1"),"GBK");
Win-->Unix
String unix=new String(win.getBytes("GBK"),"ISO8859-1");Top
4 楼aliang_2008(随风翱翔)回复于 2006-03-13 21:21:45 得分 0
private void OutputXML(Document docXML, File strFilename) {
XMLOutputter fmt = new XMLOutputter();
try {
//输出文件对象
Format format = Format.getPrettyFormat();
format.setEncoding("GBK");
fmt.setFormat(format);
fmt.output(docXML, System.out);//这里输出中文
FileWriter fwXML = new FileWriter(strFilename);
fmt.output(docXML, fwXML); //变??
fwXML.close();
}catch (Exception e) {
e.printStackTrace();
}
}
求救Top
5 楼ywb1973(谁)(★☆◎☆★)回复于 2006-03-14 19:55:09 得分 0
你的Format类和XMLOutputter类是哪个包里的?怎么方法和我见到的不一样呀!?
如果你用jdom,可以直接读iso8859的XML文件,不用转码了Top




