mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
utf8: make EncodeRune's destination the first argument.
R=r CC=golang-dev https://golang.org/cl/3364041
This commit is contained in:
parent
287045085d
commit
3cb4bdb9ce
14 changed files with 21 additions and 233 deletions
|
|
@ -831,13 +831,13 @@ func unquote(s []byte) (t string, ok bool) {
|
|||
if dec := utf16.DecodeRune(rune, rune1); dec != unicode.ReplacementChar {
|
||||
// A valid pair; consume.
|
||||
r += 6
|
||||
w += utf8.EncodeRune(dec, b[w:])
|
||||
w += utf8.EncodeRune(b[w:], dec)
|
||||
break
|
||||
}
|
||||
// Invalid surrogate; fall back to replacement rune.
|
||||
rune = unicode.ReplacementChar
|
||||
}
|
||||
w += utf8.EncodeRune(rune, b[w:])
|
||||
w += utf8.EncodeRune(b[w:], rune)
|
||||
}
|
||||
|
||||
// Quote, control characters are invalid.
|
||||
|
|
@ -854,7 +854,7 @@ func unquote(s []byte) (t string, ok bool) {
|
|||
default:
|
||||
rune, size := utf8.DecodeRune(s[r:])
|
||||
r += size
|
||||
w += utf8.EncodeRune(rune, b[w:])
|
||||
w += utf8.EncodeRune(b[w:], rune)
|
||||
}
|
||||
}
|
||||
return string(b[0:w]), true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue