]> Cypherpunks.ru repositories - gostls13.git/commit
all: make Unicode surrogate halves illegal as UTF-8
authorRob Pike <r@golang.org>
Wed, 8 Aug 2012 21:01:23 +0000 (14:01 -0700)
committerRob Pike <r@golang.org>
Wed, 8 Aug 2012 21:01:23 +0000 (14:01 -0700)
commitc48b77b1b5e5ac38351487583a1082b7b73d0ffe
treed2c3a78b82641f40d35da4e6258b11dbfa78dfe9
parent4939b7b065d2eee1c37201c0d42ed4dd06d22265
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
src/pkg/runtime/rune.c
src/pkg/unicode/utf8/utf8.go
src/pkg/unicode/utf8/utf8_test.go
test/stringrange.go