Skip to content

Add Path::display_lossy() and display_escaped() methodsΒ #82195

Open
@sunshowers

Description

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 the Debug impl if there are invalid UTF-8 bytes, or the current display() 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() to display_lossy() (and perhaps deprecate display() in a new Rust edition?)

cc @Manishearth (who requested I file this), @m-ou-se

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-strArea: str and StringC-feature-requestCategory: A feature request, i.e: not implemented / a PR.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