rust-lang / rust-lang/rust

`std::ascii::escape_default` unexpectedly prints in LowerHex even though documentation specifies UpperHex

Open
#152,580 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-discussion T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

println!("{}", std::ascii::escape_default(0xFF));

As per the documentation for std::ascii::escape_default:

Any other chars are given hex escapes of the form \xNN.

I expected it to print "\xFF", but instead it printed "\xff".
See Playground

Meta

rustc --version --verbose:

1.93.0

same issue in beta and nightly channels obviously.

I couldn't find whether this has been reported previously. Can someone confirm whether this is a bug or outdated documentation? If so, I will prepare a PR to fix it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with std::ascii::escape_default and the linked standard-library documentation, then reproduce the output with the provided snippet or Playground. Determine whether the implementation or documentation defines the intended hex casing; done means the behavior and documentation agree, with an appropriate regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.