Hi,
This has been discussed when we did JEP 400: UTF-8 by Default and
decided not to do it, mainly because it affects filename/path encoding.
Changing `sun.jnu.encoding` apart from Windows system encoding will make
apps not being able to access those files/directories (e.g. home
directory) if the path/name contains characters with different encodings.
Naoto
On 10/30/24 8:37 AM, Fabian Meumertzheim wrote:
On Windows, java.exe determines the value of "sun.jnu.encoding" and thus
the encoding of any command-line arguments, environment variables, file
names etc. based on the process' active code page (using the GetACP()
Windows API function). On a vanilla Windows machine, this is typically a
legacy code page such as Cp1252 that is not able to represent all
Unicode characters. While it is possible to set the default system code
page to UTF-8 in recent Windows releases, this affects all applications
on the system, some of which may not be compatible with this setting.
I would like to add a way for a Java application to force this encoding
to be UTF-8 without any trickery (such as sidestepping java.exe by using
the native Invocation API and changing the processes active code page)
or modifications to global system settings. This would require changes
to libjava and the native launcher.
Are there others that would like to see such a change? Has this been
thought of or attempted before?
Fabian