java windows 上的 println 输出编码
java println output encoding on windows
这个问题源于我问的一个问题here。有人建议这可能是 Java 问题,所以我发布了另一个问题。
什么决定了system.out.println命令的输出编码?基本上,我正在从命令提示符执行一个 python 程序,它产生一个子进程 运行 java(斯坦福解析器)它接受我以 UTF-8 编码的输入文档、进程和 println我以特定格式输入。回到 python 程序,我无法使用 utf-8 解码 stdout 的输出。这适用于 OSX,所以我怀疑它可能是控制台编码问题。
我试过设置 chcp 65001
和更改字体类型,但这些都不起作用。
它使用default encoding which on Windows will be an obsolete "ANSI" encoding. The documented way to change this is "via the operating system" though this is as far as it goes. You can also call System.setOut提供你自己的机制:
System.setOut(new PrintStream(System.out, true, "UTF-8"));
请参阅 here 了解更多信息。
这个问题源于我问的一个问题here。有人建议这可能是 Java 问题,所以我发布了另一个问题。
什么决定了system.out.println命令的输出编码?基本上,我正在从命令提示符执行一个 python 程序,它产生一个子进程 运行 java(斯坦福解析器)它接受我以 UTF-8 编码的输入文档、进程和 println我以特定格式输入。回到 python 程序,我无法使用 utf-8 解码 stdout 的输出。这适用于 OSX,所以我怀疑它可能是控制台编码问题。
我试过设置 chcp 65001
和更改字体类型,但这些都不起作用。
它使用default encoding which on Windows will be an obsolete "ANSI" encoding. The documented way to change this is "via the operating system" though this is as far as it goes. You can also call System.setOut提供你自己的机制:
System.setOut(new PrintStream(System.out, true, "UTF-8"));
请参阅 here 了解更多信息。