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

Inconsistent escaping of special characters between &str and &OsStr with Debug #27211

Closed
diaphore opened this Issue Jul 22, 2015 · 0 comments

Comments

Projects
None yet
2 participants
@diaphore
Copy link
Contributor

diaphore commented Jul 22, 2015

Formatting a string containing special characters with Debug usually prints them escaped i.e."\r\n\t".

fn main() {
    use std::ffi::OsStr;

    let str = "Hello\r\n\tThere";
    let os_str: &OsStr = str.as_ref();
    println!("{:?}", str);
    println!("{:?}", os_str);
}

This snippet runs as expected in the playground. However on Windows, using both rustc 1.3.0-nightly (be23d44a5 2015-07-20) and rustc 1.1.0 (35ceea399 2015-06-19), the OsStr is printed unescaped :

"Hello\r\n\tThere"
"Hello
    there"

From what I can gather, impl fmt::Debug for Wtf8 only concerns itself with faulty surrogates and completely ignores special characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.