package jsonstring
type nibbleTables struct {
Lo [16 ]byte
Hi [16 ]byte
}
func newNibbleTables(need *[256 ]bool ) nibbleTables {
var t nibbleTables
bits := map [uint16 ]byte {}
next := byte (1 )
for hi := 0 ; hi < 16 ; hi ++ {
var set uint16
for lo := 0 ; lo < 16 ; lo ++ {
if need [hi <<4 |lo ] {
set |= 1 << lo
}
}
if set == 0 {
continue
}
bit , ok := bits [set ]
if !ok {
if next == 0 {
panic ("too many sets of the low nibbles for the tables of the scan" )
}
bit = next
next <<= 1
bits [set ] = bit
for lo := 0 ; lo < 16 ; lo ++ {
if set &(1 <<lo ) != 0 {
t .Lo [lo ] |= bit
}
}
}
t .Hi [hi ] = bit
}
return t
}
type utf8Tables struct {
Byte1High [16 ]byte
Byte1Low [16 ]byte
Byte2High [16 ]byte
}
const (
utf8TooShort = 1 << 0
utf8TooLong = 1 << 1
utf8Overlong3 = 1 << 2
utf8TooLarge = 1 << 3
utf8Surrogate = 1 << 4
utf8Overlong2 = 1 << 5
utf8TooLarge1000 = 1 << 6
utf8Overlong4 = 1 << 6
utf8TwoConts = 1 << 7
utf8Carry = utf8TooShort | utf8TooLong | utf8TwoConts
)
var utf8ValidationTables = utf8Tables {
Byte1High : [16 ]byte {
utf8TooLong , utf8TooLong , utf8TooLong , utf8TooLong , utf8TooLong , utf8TooLong , utf8TooLong , utf8TooLong ,
utf8TwoConts , utf8TwoConts , utf8TwoConts , utf8TwoConts ,
utf8TooShort | utf8Overlong2 ,
utf8TooShort ,
utf8TooShort | utf8Overlong3 | utf8Surrogate ,
utf8TooShort | utf8TooLarge | utf8TooLarge1000 | utf8Overlong4 ,
},
Byte1Low : [16 ]byte {
utf8Carry | utf8Overlong3 | utf8Overlong2 | utf8Overlong4 ,
utf8Carry | utf8Overlong2 ,
utf8Carry ,
utf8Carry ,
utf8Carry | utf8TooLarge ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 | utf8Surrogate ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
utf8Carry | utf8TooLarge | utf8TooLarge1000 ,
},
Byte2High : [16 ]byte {
utf8TooShort , utf8TooShort , utf8TooShort , utf8TooShort , utf8TooShort , utf8TooShort , utf8TooShort , utf8TooShort ,
utf8TooLong | utf8Overlong2 | utf8TwoConts | utf8Overlong3 | utf8TooLarge1000 | utf8Overlong4 ,
utf8TooLong | utf8Overlong2 | utf8TwoConts | utf8Overlong3 | utf8TooLarge ,
utf8TooLong | utf8Overlong2 | utf8TwoConts | utf8Surrogate | utf8TooLarge ,
utf8TooLong | utf8Overlong2 | utf8TwoConts | utf8Surrogate | utf8TooLarge ,
utf8TooShort , utf8TooShort , utf8TooShort , utf8TooShort ,
},
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .