-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
relnotesMarks issues that should be documented in the release notes of the next release.Marks issues that should be documented in the release notes of the next release.
Description
While trying to open a non-existing file (on Windows 10, Chinese):
use std::fs::File;
fn main() {
File::open("no-such-file.rs").unwrap();
}
It panicked with a message:
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "\u{7cfb}\u{7edf}\u{627e}\u{4e0d}\u{5230}\u{6307}\u{5b9a}\u{7684}\u{6587}\u{4ef6}\u{3002}" } }', ../src/libcore\result.rs:746
note: Run with `RUST_BACKTRACE=1` for a backtrace.
The OS native error message here is unreadable for human being.
The message ("\u{7cfb}\u{7edf}\u{627e}\u{4e0d}\u{5230}..."
) is the escaped result of "No such file or directory" in Chinese ("系统找不到指定的文件")。impl fmt::Debug for str
do this escape.
I can read Chinese, which is my mother tongue, but I can't read \u{7cfb}...
.
Possible solutions:
- Don't use local language (Chinese here) OS error string, use English instead.
- Change
impl fmt::Debug for str
to not escape most Unicode chars. (breaking-change?)
fn main() {
let s = "Hello δεΣ❤ 日月";
println!("{}", s); // prints "Hello δεΣ❤ 日月"
println!("{:?}", s); // prints "Hello \u{3b4}\u{3b5}\u{3a3}\u{2764} \u{65e5}\u{6708}"
}
Is impl fmt::Debug for str
really friendly enough for debug purpose? Is there possibility that we change its implementation as similar as impl fmt::Display for str
?
Metadata
Metadata
Assignees
Labels
relnotesMarks issues that should be documented in the release notes of the next release.Marks issues that should be documented in the release notes of the next release.