import java.io.PrintStream;class Kyrill { public static void main(String args[]) throws java.io.UnsupportedEncodingException { String ru = "Русский язык"; PrintStream ps = new PrintStream(System.out, true, "UTF-8"); System.out.println(ru.length()); System.out.println(ru); ps.println(ru); }}D:Temp :: chcp 65001Aktive Codepage: 65001.D:Temp :: javac -encoding utf-8 Kyrill.java && java Kyrill12??????? ????Русский языкй язык请注意,您可能会在输出中看到一些尾随的垃圾(我确实如此),但是如果将输出重定向到文件,则会看到这只是一个显示伪像。
因此,您可以使用PrintStream使其工作。该System.out中使用该平台的编码(CP1252对我来说),而且没有西里尔字母。
供您使用编码业务的其他说明:
D:Temp :: chcp 1251Aktive Codepage: 1251.:: This is another prepage (8 bits only) that maps bytes to cyrillic characters.:: Edit the source file to have::: PrintStream ps = new PrintStream(System.out, true, "Windows-1251");:: We intend to match the console output; else we won't get the expected result.D:Temp :: javac -encoding utf-8 Kyrill.java && java Kyrill12??????? ????Русский язык
因此,您会发现与某些人的看法相反,Windows控制台在偶然的意义上 确实会破坏Unipre ,因为它可以打印希腊语和俄语。



