utf8: make EncodeRune's destination the first argument.

R=r
CC=golang-dev
https://golang.org/cl/3364041
This commit is contained in:
Adam Langley 2010-11-30 16:59:43 -05:00
parent 287045085d
commit 3cb4bdb9ce
14 changed files with 21 additions and 233 deletions

View file

@ -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