Surrogate halves are part of UTF-16 and should never appear in UTF-8.
(The rune that two combined halves represent in UTF-16 should
be encoded directly.)
Encoding: encode as RuneError.
Decoding: convert to RuneError, consume one byte.
This requires changing:
package unicode/utf8
runtime for range over string
Also added utf8.ValidRune and fixed bug in utf.RuneLen.
Fixes#3927.
R=golang-dev, rsc, bsiegert
CC=golang-dev
https://golang.org/cl/6458099
add test for string range.
test has minor failure: after loop the index == len(s); should be len(s)-1
in this case. according to spec, vars are left at position at last
iteration.
R=ken,rsc
DELTA=259 (161 added, 96 deleted, 2 changed)
OCL=27343
CL=27343