]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #34485 - tbu-:pr_unicode_debug_str, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 28 Jul 2016 18:20:33 +0000 (11:20 -0700)
committerGitHub <noreply@github.com>
Thu, 28 Jul 2016 18:20:33 +0000 (11:20 -0700)
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/

1  2 
src/librustc_unicode/char.rs

Simple merge