开发者

How to change file encoding table in java

开发者 https://www.devze.com 2023-03-14 12:02 出处:网络
I have my code to check encoding table: System.out.println(\"enc. table: \"+System.getProperty(\"file.encoding\") +

I have my code to check encoding table:

System.out.println("enc. table: "+System.getProperty("file.encoding") +
          "enc. table: "+new java.io.OutputStreamWriter(new java.io.ByteArrayOutputStream()).getEncoding() + 
          "enc. table:" + java.nio.charset.Charset.defaultCharset().name());

When I start my from windows I get text file with cp1250, when 开发者_如何转开发I start from my embedded system I get text file with cp852. In windows I have set code page 852. In Eclipse I have set cp852. Some solution?


You should really be specifing the required encoding on the OutputStreamWriter.

new OutputStreamWriter(outstream, "cp852");

You may also want to read Joels article The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets

0

精彩评论

暂无评论...
验证码 换一张
取 消