-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Use non-local OS error strings (en-US) #34422
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Is there precedence of other programming languages doing this? From the top of my head, I only know that Python doesn't. I don't think this is a good idea, we shouldn't impose English upon the user. If you have, say, a Windows in German, then it is expected that all strings by the operating system actually are in German. |
Maybe we should rather escape less characters in the |
I'd rather disable escaping only for OS error strings specifically, not for all strings. |
@retep998 I believe Python has a good strategy here, and they don't escape most Unicode symbols, except for weird ones like zero-width space (U+200B):
Equivalent Rust:
Outputs:
|
Escape fewer Unicode codepoints in `Debug` impl of `str` Use the same procedure as Python to determine whether a character is printable, described in [PEP 3138]. In particular, this means that the following character classes are escaped: - Cc (Other, Control) - Cf (Other, Format) - Cs (Other, Surrogate), even though they can't appear in Rust strings - Co (Other, Private Use) - Cn (Other, Not Assigned) - Zl (Separator, Line) - Zp (Separator, Paragraph) - Zs (Separator, Space), except for the ASCII space `' '` `0x20` This allows for user-friendly inspection of strings that are not English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`). Fixes #34318. CC #34422. [PEP 3138]: https://www.python.org/dev/peps/pep-3138/
Closes #34318