Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS.execute should output PackedByteArray? #60897

Closed
CsloudX opened this issue May 9, 2022 · 2 comments · Fixed by #60920
Closed

OS.execute should output PackedByteArray? #60897

CsloudX opened this issue May 9, 2022 · 2 comments · Fixed by #60920
Milestone

Comments

@CsloudX
Copy link

CsloudX commented May 9, 2022

Godot version

v4.0.alpha7.official [3e9ead0]

System information

windows10 64bit

Issue description

When I execute my PowerShell command on PowerShell's window, it output like this:
1
And I coding GDScript like this:
2
But It prints like this:
3
Because PowerShell return not valid UTF-8, so I think maybe OS.execute should output PackedByteArray and I can code like this for solve this problem:
4

Steps to reproduce

Please run the reproduction project

Minimal reproduction project

OsExecTest.zip

@timothyqiu
Copy link
Member

timothyqiu commented May 9, 2022

Because PowerShell return not valid UTF-8

FYI: This behavior is not limited to PowerShell, using Command Prompt has the same issue if I remember correctly.

As the default output encoding on Windows is system locale dependent, It seems that we should either use PackedByteArray instead of String, or find a way to retrieve the "Unicode" output.

@bruvzg
Copy link
Member

bruvzg commented May 10, 2022

PackedByteArray won't help, Windows console output default to ASCII, so it's not sending full characters through the pipe.
Normally, encoding can be set be the shell (using chcp command) or app that's writing to the console SetConsoleOutputCP, but seems like it can't be set by the parent process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants