message, unicode/cldr: avoid string(int)
Updates golang/go#32479
Change-Id: Idd10c8208aaa006b3c80b90644e540a8af3572c0
Reviewed-on: https://go-review.googlesource.com/c/text/+/233899
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/message/fmt_test.go b/message/fmt_test.go
index 2d6872b..42de593 100644
--- a/message/fmt_test.go
+++ b/message/fmt_test.go
@@ -257,10 +257,10 @@
{"%#q", "\U0010ffff", "``"},
{"%#+q", "\U0010ffff", "``"},
// Runes that are not valid.
- {"%q", string(0x110000), `"�"`},
- {"%+q", string(0x110000), `"\ufffd"`},
- {"%#q", string(0x110000), "`�`"},
- {"%#+q", string(0x110000), "`�`"},
+ {"%q", string(rune(0x110000)), `"�"`},
+ {"%+q", string(rune(0x110000)), `"\ufffd"`},
+ {"%#q", string(rune(0x110000)), "`�`"},
+ {"%#+q", string(rune(0x110000)), "`�`"},
// characters
{"%c", uint('x'), "x"},
@@ -1451,7 +1451,7 @@
s := "%"
for i := 0; i < 128; i++ {
if f.Flag(i) {
- s += string(i)
+ s += string(rune(i))
}
}
if w, ok := f.Width(); ok {
diff --git a/unicode/cldr/base.go b/unicode/cldr/base.go
index 63cdc16..b71420c 100644
--- a/unicode/cldr/base.go
+++ b/unicode/cldr/base.go
@@ -98,7 +98,7 @@
func replaceUnicode(s string) string {
if s[1] == '#' {
r, _ := strconv.ParseInt(s[3:len(s)-1], 16, 32)
- return string(r)
+ return string(rune(r))
}
r, _, _, _ := strconv.UnquoteChar(s, 0)
return string(r)