Skip to content

Commit 81608d7

Browse files
committed
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent afb9336 commit 81608d7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

message/fmt_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ var fmtTests = []struct {
257257
{"%#q", "\U0010ffff", "`􏿿`"},
258258
{"%#+q", "\U0010ffff", "`􏿿`"},
259259
// Runes that are not valid.
260-
{"%q", string(0x110000), `"�"`},
261-
{"%+q", string(0x110000), `"\ufffd"`},
262-
{"%#q", string(0x110000), "`�`"},
263-
{"%#+q", string(0x110000), "`�`"},
260+
{"%q", string(rune(0x110000)), `"�"`},
261+
{"%+q", string(rune(0x110000)), `"\ufffd"`},
262+
{"%#q", string(rune(0x110000)), "`�`"},
263+
{"%#+q", string(rune(0x110000)), "`�`"},
264264

265265
// characters
266266
{"%c", uint('x'), "x"},
@@ -1451,7 +1451,7 @@ func (flagPrinter) Format(f fmt.State, c rune) {
14511451
s := "%"
14521452
for i := 0; i < 128; i++ {
14531453
if f.Flag(i) {
1454-
s += string(i)
1454+
s += string(rune(i))
14551455
}
14561456
}
14571457
if w, ok := f.Width(); ok {

unicode/cldr/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ var charRe = regexp.MustCompile(`&#x[0-9a-fA-F]*;|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-
9898
func replaceUnicode(s string) string {
9999
if s[1] == '#' {
100100
r, _ := strconv.ParseInt(s[3:len(s)-1], 16, 32)
101-
return string(r)
101+
return string(rune(r))
102102
}
103103
r, _, _, _ := strconv.UnquoteChar(s, 0)
104104
return string(r)

0 commit comments

Comments
 (0)