elharo opened a new pull request, #208: URL: https://github.com/apache/maven-script-interpreter/pull/208
Partially fixes #206. `MirrorStreamWrapper` decodes bytes mirrored to the `FileLoggerMirrorHandler` using `new String(b, off, len)`, which uses the platform default charset. This makes build output depend on the host encoding. This change passes an explicit `Charset` to the wrapper and uses `StandardCharsets.UTF_8` in the `FileLogger` constructor, so the mirror handler always receives UTF-8-decoded strings regardless of platform default. The single-byte `write(int b)` method (FileLogger.java:147-149) casts the int to char, which is equivalent to a platform-default decode for high bytes. This PR does not change that path, as it is a separate concern and the single-byte write path is not commonly used for multi-byte text. Includes a test (`mirrorShouldDecodeBytesAsUtf8`) that writes non-ASCII UTF-8 bytes and asserts the mirror handler receives the correct string. On a platform whose default charset is not UTF-8, this test would fail on the old code and pass with this fix. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
