strconv: quote rune 007F as \x7f, not \u007f
\u007f is not wrong but it's weird to use \u when we could use the
shorter \x.
Fixes #52062
Change-Id: Ica4bdc2463128051876f44e15297ed1e9edf1de8
Reviewed-on: https://go-review.googlesource.com/c/go/+/397255
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/api/go1.1.txt b/api/go1.1.txt
index bb00b3b..06291fa 100644
--- a/api/go1.1.txt
+++ b/api/go1.1.txt
@@ -371,7 +371,7 @@
pkg debug/elf, const ELFDATA2LSB = 1
pkg debug/elf, const ELFDATA2MSB = 2
pkg debug/elf, const ELFDATANONE = 0
-pkg debug/elf, const ELFMAG = "\u007fELF"
+pkg debug/elf, const ELFMAG = "\x7fELF"
pkg debug/elf, const ELFOSABI_86OPEN = 5
pkg debug/elf, const ELFOSABI_AIX = 7
pkg debug/elf, const ELFOSABI_ARM = 97
diff --git a/doc/go1.19.html b/doc/go1.19.html
index c0e2cf1..cfeb3d3 100644
--- a/doc/go1.19.html
+++ b/doc/go1.19.html
@@ -90,4 +90,14 @@
issue tracker</a>.
</p>
</dd>
-</dl>
+</dl><!-- net -->
+
+<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
+ <dd>
+ <p><!-- CL 397255 -->
+ <a href="/pkg/strconv/#strconv.Quote"><code>strconv.Quote</code></a>
+ and related functions now quote the rune 007F as <code>\x7f</code>,
+ not <code>\u007f</code>.
+ </p>
+ </dd>
+</dl><!-- strconv -->
diff --git a/src/strconv/quote.go b/src/strconv/quote.go
index 9d20b75..6c02284 100644
--- a/src/strconv/quote.go
+++ b/src/strconv/quote.go
@@ -99,7 +99,7 @@
buf = append(buf, `\v`...)
default:
switch {
- case r < ' ':
+ case r < ' ' || r == 0x7f:
buf = append(buf, `\x`...)
buf = append(buf, lowerhex[byte(r)>>4])
buf = append(buf, lowerhex[byte(r)&0xF])
diff --git a/src/strconv/quote_test.go b/src/strconv/quote_test.go
index 81fc8f7..fc000de 100644
--- a/src/strconv/quote_test.go
+++ b/src/strconv/quote_test.go
@@ -55,6 +55,7 @@
{"\x04", `"\x04"`, `"\x04"`, `"\x04"`},
// Some non-printable but graphic runes. Final column is double-quoted.
{"!\u00a0!\u2000!\u3000!", `"!\u00a0!\u2000!\u3000!"`, `"!\u00a0!\u2000!\u3000!"`, "\"!\u00a0!\u2000!\u3000!\""},
+ {"\x7f", `"\x7f"`, `"\x7f"`, `"\x7f"`},
}
func TestQuote(t *testing.T) {