Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strconv: treat \x7f like the rest of ASCII when quoting #52062

Closed
robpike opened this issue Mar 31, 2022 · 3 comments
Closed

strconv: treat \x7f like the rest of ASCII when quoting #52062

robpike opened this issue Mar 31, 2022 · 3 comments

Comments

@robpike
Copy link
Contributor

robpike commented Mar 31, 2022

See https://go.dev/play/p/F4GlQBQL7UC

As mentioned in https://groups.google.com/d/msgid/golang-nuts/60ad41f0-10d6-417d-a604-6a151c357d93n%40googlegroups.com (which started a decade ago, almost)
, the 0x7f byte prints with \u not \x. That isn't incorrect, but it is inconsistent.

If it's worth fixing, it's a one-liner in strconv.appendEscapedRune

I vote for fixing it, although it could break some things. It trips over just what ASCII means, and to be honest \x7f is the ASCII rubout or del character.

@robpike robpike changed the title affected/package: strconv: treat \x7f like the rest of ASCII when quoting Mar 31, 2022
@peterGo
Copy link
Contributor

peterGo commented Mar 31, 2022

The Unicode Standard classifies 007F as a Control Character. The other Control Characters print as \x, 007F should print as \x.

Unicode Standard
http://www.unicode.org/versions/latest/

C0 Controls and Basic Latin
Range: 0000–007F
https://unicode.org/charts/PDF/U0000.pdf

Control character 007F  control = DELETE

@zamicol
Copy link
Contributor

zamicol commented Mar 31, 2022

I wrote a larger test that prints the extended range. Everything is as I would expect except for \x7F.

https://go.dev/play/p/j_Mm9O98hnz

@gopherbot
Copy link

Change https://go.dev/cl/397255 mentions this issue: strconv: quote rune 007F as \x7f, not \u007f

@golang golang locked and limited conversation to collaborators Mar 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants