diff options
author | Russ Cox <rsc@golang.org> | 2022-03-08 09:51:29 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2022-03-16 16:28:38 +0000 |
commit | 3efc7215cbf6c7842cba0f5ebe90f72f0b6de9e1 (patch) | |
tree | ba1181553e3872c907d3035e13ba90bed135d6e0 /src/strconv | |
parent | 33e752edd3f5fa5b738730513a7c1283d8e98fa2 (diff) | |
download | go-3efc7215cbf6c7842cba0f5ebe90f72f0b6de9e1.tar.gz go-3efc7215cbf6c7842cba0f5ebe90f72f0b6de9e1.zip |
fmt, strconv: document use of Unicode replacement character in %q
Fixes #51526.
Change-Id: I365a763454bd201f804df29f800416b1731b8ebc
Reviewed-on: https://go-review.googlesource.com/c/go/+/390436
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/strconv')
-rw-r--r-- | src/strconv/quote.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/strconv/quote.go b/src/strconv/quote.go index d2814b92da..9d20b75a58 100644 --- a/src/strconv/quote.go +++ b/src/strconv/quote.go @@ -165,6 +165,8 @@ func AppendQuoteToGraphic(dst []byte, s string) []byte { // QuoteRune returns a single-quoted Go character literal representing the // rune. The returned string uses Go escape sequences (\t, \n, \xFF, \u0100) // for control characters and non-printable characters as defined by IsPrint. +// If r is not a valid Unicode code point, it is interpreted as the Unicode +// replacement character U+FFFD. func QuoteRune(r rune) string { return quoteRuneWith(r, '\'', false, false) } @@ -179,6 +181,8 @@ func AppendQuoteRune(dst []byte, r rune) []byte { // the rune. The returned string uses Go escape sequences (\t, \n, \xFF, // \u0100) for non-ASCII characters and non-printable characters as defined // by IsPrint. +// If r is not a valid Unicode code point, it is interpreted as the Unicode +// replacement character U+FFFD. func QuoteRuneToASCII(r rune) string { return quoteRuneWith(r, '\'', true, false) } @@ -193,6 +197,8 @@ func AppendQuoteRuneToASCII(dst []byte, r rune) []byte { // the rune. If the rune is not a Unicode graphic character, // as defined by IsGraphic, the returned string will use a Go escape sequence // (\t, \n, \xFF, \u0100). +// If r is not a valid Unicode code point, it is interpreted as the Unicode +// replacement character U+FFFD. func QuoteRuneToGraphic(r rune) string { return quoteRuneWith(r, '\'', false, true) } |