Skip to content

Commit

Permalink
message, unicode/cldr: avoid string(int)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bradfitz committed May 13, 2020
1 parent afb9336 commit 81608d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions message/fmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ var fmtTests = []struct {
{"%#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"},
Expand Down Expand Up @@ -1451,7 +1451,7 @@ func (flagPrinter) Format(f fmt.State, c rune) {
s := "%"
for i := 0; i < 128; i++ {
if f.Flag(i) {
s += string(i)
s += string(rune(i))
}
}
if w, ok := f.Width(); ok {
Expand Down
2 changes: 1 addition & 1 deletion unicode/cldr/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var charRe = regexp.MustCompile(`&#x[0-9a-fA-F]*;|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-
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)
Expand Down

0 comments on commit 81608d7

Please sign in to comment.