aboutsummaryrefslogtreecommitdiff
path: root/test/stringrange.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2012-08-08 14:01:23 -0700
committerRob Pike <r@golang.org>2012-08-08 14:01:23 -0700
commitc48b77b1b5e5ac38351487583a1082b7b73d0ffe (patch)
treed2c3a78b82641f40d35da4e6258b11dbfa78dfe9 /test/stringrange.go
parent4939b7b065d2eee1c37201c0d42ed4dd06d22265 (diff)
downloadgo-c48b77b1b5e5ac38351487583a1082b7b73d0ffe.tar.gz
go-c48b77b1b5e5ac38351487583a1082b7b73d0ffe.zip
all: make Unicode surrogate halves illegal as UTF-8
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
Diffstat (limited to 'test/stringrange.go')
-rw-r--r--test/stringrange.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/stringrange.go b/test/stringrange.go
index daaba91c69..99e5edb5a4 100644
--- a/test/stringrange.go
+++ b/test/stringrange.go
@@ -57,6 +57,13 @@ func main() {
ok = false
}
+ for _, c := range "a\xed\xa0\x80a" {
+ if c != 'a' && c != utf8.RuneError {
+ fmt.Printf("surrogate UTF-8 does not error: %U\n", c)
+ ok = false
+ }
+ }
+
if !ok {
fmt.Println("BUG: stringrange")
os.Exit(1)