Add Path::display_lossy() and display_escaped() methodsΒ #82195
Open
Description
opened on Feb 16, 2021
Currently Path
has:
- a single
display()
method which converts any invalid UTF-8 bytes to REPLACEMENT CHARACTER (U+FFFD) - a
Debug
impl that always adds quotes and escapes invalid UTF-8 bytes
This can result in some confusion because people that "just want to print a path" may end up inadvertently producing lossy output.
It would be great to:
- add a
display_escaped()
method which is similar to theDebug
impl if there are invalid UTF-8 bytes, or the currentdisplay()
impl if there aren't. In other words:- if there are invalid UTF-8 byte sequences, it adds quotes and escapes those byte sequences
- if not, then it doesn't add quotes.
- rename
display()
todisplay_lossy()
(and perhaps deprecatedisplay()
in a new Rust edition?)
cc @Manishearth (who requested I file this), @m-ou-se
Activity