mirror of
https://github.com/json-iterator/go.git
synced 2025-04-23 11:37:32 +02:00
Update feature_iter_string.go Update feature_iter_string.go
This commit is contained in:
parent
9d1feb5431
commit
696f962eda
@ -59,7 +59,7 @@ func (iter *Iterator) readStringSlowPath(str []byte) (ret string) {
|
|||||||
if c == '\\' {
|
if c == '\\' {
|
||||||
c = iter.readByte()
|
c = iter.readByte()
|
||||||
switch c {
|
switch c {
|
||||||
case 'u':
|
case 'u', 'U':
|
||||||
r := iter.readU4()
|
r := iter.readU4()
|
||||||
if utf16.IsSurrogate(r) {
|
if utf16.IsSurrogate(r) {
|
||||||
c = iter.readByte()
|
c = iter.readByte()
|
||||||
@ -75,7 +75,7 @@ func (iter *Iterator) readStringSlowPath(str []byte) (ret string) {
|
|||||||
if iter.Error != nil {
|
if iter.Error != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c != 'u' {
|
if c != 'u' && c != 'U' {
|
||||||
iter.reportError("ReadString",
|
iter.reportError("ReadString",
|
||||||
`expects \u after utf16 surrogate, but \u not found`)
|
`expects \u after utf16 surrogate, but \u not found`)
|
||||||
return
|
return
|
||||||
@ -157,6 +157,8 @@ func (iter *Iterator) readU4() (ret rune) {
|
|||||||
ret = ret * 16 + rune(c - '0')
|
ret = ret * 16 + rune(c - '0')
|
||||||
} else if c >= 'a' && c <= 'f' {
|
} else if c >= 'a' && c <= 'f' {
|
||||||
ret = ret * 16 + rune(c - 'a' + 10)
|
ret = ret * 16 + rune(c - 'a' + 10)
|
||||||
|
} else if c >= 'A' && c <= 'F' {
|
||||||
|
ret = ret * 16 + rune(c - 'A' + 10)
|
||||||
} else {
|
} else {
|
||||||
iter.reportError("readU4", "expects 0~9 or a~f")
|
iter.reportError("readU4", "expects 0~9 or a~f")
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user