我需要用PC8字符编码用Java编写一个文件。如何将“自定义”字符集应用于(文本)文件?
这就是我想做的:
try {
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("test.txt"), "utf-8")); // obviously need to change this
String info = "#TEST \"test åäö\"";
writer.write(info);
writer.close();
} catch (Exception e) {
System.out.println(e);
} 所以我需要知道是否有可能用一个特殊的字符编码来写,我需要做什么呢?在编码中指定"PC-8“或"PC8”无效。
发布于 2014-07-15 13:18:14
我在写问题的时候找到了答案。以下是支持的Java字符编码列表,以及如何在我在问题:http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html中提供的代码块中指定它们
所以这是对我有用的:
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("test.txt"), "ibm-437"));在我的例子中,引起问题的是Google到处都是关于UTF-8字符编码的问题。此外,PC8不是字符编码的正式名称,因此我无法找到该名称所需的信息。希望这通常有助于解决编码问题。
https://stackoverflow.com/questions/24759279
复制相似问题