Skip to content

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

Closed
@diaphore

Description

@diaphore

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions