Allowing apps to force sun.jnu.encoding = "UTF-8" on Windows

Fabian Meumertzheim fabian at buildbuddy.io
Wed Oct 30 15:37:55 UTC 2024


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20241030/59dbfaa0/attachment-0001.htm>


More information about the core-libs-dev mailing list