Try to convert OS::execute()
output to Unicode on Windows
#60920
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.
Resolves #60897
Windows defaults to ANSI instead of 8-bit ASCII. Full characters are sent but using different encodings according to the code page. This is why godot prints lots of "Unicode parsing error" when trying to interpret these bytes as UTF-8 which is most of the time an incorrect encoding (but compatible with the ASCII part).
This PR uses
MultiByteToWideChar
to convert the output bytes from system default ANSI encoding to Unicode (wchar_t
) so that aString
can be constructed correctly. If the API fails, we fallback to the original "treat as UTF-8" approach.I only tested this on a Simplified Chinese version of Windows. CC @bruvzg
For cherry-pick:
is_empty()
→empty()
.