Description:
When formatting a UTF-8 file on Windows using Java 18 or higher (I'm using Java 25), characters with accents/tildes are replaced with the � replacement character.
Root Cause:
The extension communicates with the JVM daemon via stdin/stdout. Starting in Java 18 (JEP 400), while file.encoding defaults to UTF-8, the Standard I/O streams (System.out, System.in, System.err) default to the native console encoding (e.g., CP1252 or CP850 on Windows). Because the daemon reads and writes the JSON payload via stdio without forcing UTF-8, the characters get mangled during the VS Code <-> JVM IPC exchange.
Workaround used:
I was able to fix this locally by adding the following to my palantirJavaFormat.jvmArgs:
-Dfile.encoding=UTF-8
-Dstdout.encoding=UTF-8
-Dstderr.encoding=UTF-8
-Dstdin.encoding=UTF-8
Suggested Fix for the Extension:
To fix this for all users out of the box, you could either:
- (Extension side): Automatically inject these encoding flags into the JVM arguments when spawning the daemon process in
extension.ts.
- (Daemon side): Explicitly wrap
System.in and System.out using StandardCharsets.UTF_8 inside the Java daemon when handling the I/O streams, rather than relying on the platform's default standard stream encoding.
Description:
When formatting a UTF-8 file on Windows using Java 18 or higher (I'm using Java 25), characters with accents/tildes are replaced with the
�replacement character.Root Cause:
The extension communicates with the JVM daemon via
stdin/stdout. Starting in Java 18 (JEP 400), whilefile.encodingdefaults to UTF-8, the Standard I/O streams (System.out,System.in,System.err) default to the native console encoding (e.g.,CP1252orCP850on Windows). Because the daemon reads and writes the JSON payload via stdio without forcing UTF-8, the characters get mangled during the VS Code <-> JVM IPC exchange.Workaround used:
I was able to fix this locally by adding the following to my
palantirJavaFormat.jvmArgs:Suggested Fix for the Extension:
To fix this for all users out of the box, you could either:
extension.ts.System.inandSystem.outusingStandardCharsets.UTF_8inside the Java daemon when handling the I/O streams, rather than relying on the platform's default standard stream encoding.