K
K
Konstantin2015-05-30 15:27:43
Java
Konstantin, 2015-05-30 15:27:43

Java 8 and Java 7. Differences in the operation of the print method of the PrintStream class. What to read on this issue?

It is known that in java 7, as in older versions, in order for System.out.print("Hello") to display Russian text correctly in the Windows console, it was necessary:
​​1) in the operating system as a program language, not supporting Unicode, set the Russian language;
2) in the console, select the "correct" font and encoding 1251 (chcp 1251).
Today I found that when using java 1.8, the above code is correctly displayed both when the encoding is set to 866 in the console, and even if the language of programs that do not support Unicode is set to a non-Russian language.
Searching the Internet for changes in the implementation of the print method did not yield any results.
It felt like I was the first to discover this phenomenon.
Did I search badly? I would be grateful for links.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Power, 2015-05-31
@konstant2in

In java 7, there is no encoding specification for System.out (and System.err), i.e. the default encoding is used (Charset.defaultCharset(), usually taken from the "file.encoding" environment variable): hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/55f6804b4...
Java 8 already has an encoding specification (and specifically for windows it tries to match the console encoding): hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/f7a249818...
Edit: hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/ d38fed7d2ea7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question