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

IO.getEnv returns invalid UTF-8 on windows #3895

Closed
digama0 opened this issue Apr 13, 2024 · 4 comments
Closed

IO.getEnv returns invalid UTF-8 on windows #3895

digama0 opened this issue Apr 13, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@digama0
Copy link
Collaborator

digama0 commented Apr 13, 2024

Minimized from this Zulip thread. It appears that std::getenv on windows returns data in the current code page, so putting it directly into a lean String is not legal (because it assumes UTF-8 encoding). Other languages have faced the same issue:

Both of these languages take the approach of using the widestring version of the function (which is reliably UTF-16 (with potentially unpaired surrogates)) and manually converting it to UTF-8 (or WTF-8). This is a bit sad, I thought the A version of the function was supposed to be UTF-8. (Maybe it is, I can't test it.)

@digama0 digama0 added the bug Something isn't working label Apr 13, 2024
@Kha
Copy link
Member

Kha commented Apr 13, 2024

Is this #2554?

@digama0
Copy link
Collaborator Author

digama0 commented Apr 13, 2024

Unclear. (The issue description is a bit vague.) But I don't think so; from what I can tell #668 is about a build system issue, not runtime usage of getEnv and related functions.

@Kha
Copy link
Member

Kha commented Apr 18, 2024

No, it is not a build system issue. We set the code page of lean to UTF-8 but not yet for other Lean executables, so seems very relevant here. So your

I thought the A version of the function was supposed to be UTF-8

is indeed correct, depending on which executable that code is linked into.

@Kha
Copy link
Member

Kha commented Aug 29, 2024

Assuming duplicate of #2554

@Kha Kha closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants