public static final class Shell.Encoding
extends java.lang.Object
Charset used for encoding/decoding interactions with the "shell"
command interpreter environment. On Windows, especially, this is likely not the value of
Charset.defaultCharset() -- which is the Charset used for file content encoding.
For Windows, this method calls the Windows chcp command to determine the code page used
by a "fresh" CMD shell and returns the corresponding Charset.
The following Java system properties and values deal with encodings:
file.encodingGetLocaleInfoEx(GetUserDefaultLCID(), LOCALE_IDEFAULTANSICODEPAGE, ...);
uses code page 1252 if the GetLocaleInfoEx request fails.setlocale(LC_ALL, "") is used to establish the system's default locale; then
setlocale(LC_CTYPE, NULL) is used to fetch the character-handling aspects of the
default locale. The encoding value is parsed from the default locale name or obtained from
nl_langinfo(CODESET) depending on the values involved. On Mac OS X, if the value
is determined to be US-ASCII and none of the environment variables LANG,
LC_ALL, or LC_CTYPE are set, a value of UTF-8 is used instead.Charset.defaultCharset() is derived from this value if it represents a
supported character set.
sun.jnu.encodingGetLocaleInfoEx(GetSystemDefaultLCID(), LOCALE_IDEFAULTANSICODEPAGE, ...);
uses encoding 1252 if the GetLocaleInfoEx request fails.file.encoding above.sun.stdout.encodingGetConsoleCP(). This is actually in error -- it should rely on
GetConsoleOutputCP().sun.stderr.encodingGetConsoleCP(). This is actually in error -- it should rely on
GetConsoleOutputCP().Copyright © 2022. All rights reserved.