Allowing apps to force sun.jnu.encoding = "UTF-8" on Windows
Naoto Sato
naoto.sato at oracle.com
Thu Oct 31 22:26:50 UTC 2024
(renamed the subject back to original)
On 10/31/24 9:12 AM, Fabian Meumertzheim wrote:
>> 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.
>
> Based on grepping the source, it looks like the JDK (almost?)
> exclusively uses the -W Windows APIs to interface with the file
> system, with the active code page only being relevant for the internal
> conversion between Java strings and platform UTF-16 strings through
> `MultiByteToWideChar` and `WideCharToMultiByte` (via `CP_ACP`).
I don't believe this assumption is correct. Java runtime is implicitly
using Win32 ANSI calls, as it is not entirely compiled with `UNICODE`
flag. Those calls would fail if ANSI code page differs from UTF-8.
Naoto
More information about the core-libs-dev
mailing list