Added Unicode Support via utf-8 specification#60
Open
KennethNero wants to merge 2 commits into
Open
Conversation
Author
|
After thorough testing - also modified minescript_runtime.py to ensure that the java encoding doesn't fall off due to python's interpretation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Unicode encoding issues in NBT data transmission to Python
Summary
Fixes incorrect encoding when transmitting NBT data containing Unicode characters from Java to Python subprocess, which caused mojibake (e.g.,
⚎appearing as⚎).Problem
Fixes #59
When
SubprocessTaskwrites JSON data containing Unicode characters to Python's stdin, it usesOutputStreamWriterwithout specifying a charset. On Windows, this defaults to Windows-1252/CP1252 instead of UTF-8, causing Unicode characters in book NBT data to be corrupted.Example:
⚎⚎⚎(U+26CE)⚎⚎⚎(UTF-8 bytes misinterpreted as Windows-1252)Solution
Explicitly specify
StandardCharsets.UTF_8when creating:OutputStreamWriterfor subprocess stdin (writing to Python)InputStreamReaderfor subprocess stdout (reading from Python)InputStreamReaderfor subprocess stderr (reading from Python)Changes
common/src/main/java/net/minescript/common/SubprocessTask.java:import java.nio.charset.StandardCharsets;new OutputStreamWriter(process.getOutputStream(), StandardCharsets.UTF_8)new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8)All Unicode characters now transmit correctly to Python scripts.
Additional Notes
This is a platform-specific bug that primarily affects Windows users, where the default charset is not UTF-8. Linux/Mac users were unaffected as their default is already UTF-8.