Source File
utf8.go
Belonging Package
runtime
package runtime
const (
surrogateMin = 0xD800
surrogateMax = 0xDFFF
)
const (
t1 = 0x00 // 0000 0000
tx = 0x80 // 1000 0000
t2 = 0xC0 // 1100 0000
t3 = 0xE0 // 1110 0000
t4 = 0xF0 // 1111 0000
t5 = 0xF8 // 1111 1000
maskx = 0x3F // 0011 1111
mask2 = 0x1F // 0001 1111
mask3 = 0x0F // 0000 1111
mask4 = 0x07 // 0000 0111
rune1Max = 1<<7 - 1
rune2Max = 1<<11 - 1
rune3Max = 1<<16 - 1
switch := uint32(); {
case <= rune1Max:
[0] = byte()
return 1
case <= rune2Max:
_ = [1] // eliminate bounds checks
[0] = t2 | byte(>>6)
[1] = tx | byte()&maskx
return 2
case > maxRune, surrogateMin <= && <= surrogateMax:
= runeError
fallthrough
case <= rune3Max:
_ = [2] // eliminate bounds checks
[0] = t3 | byte(>>12)
[1] = tx | byte(>>6)&maskx
[2] = tx | byte()&maskx
return 3
default:
_ = [3] // eliminate bounds checks
[0] = t4 | byte(>>18)
[1] = tx | byte(>>12)&maskx
[2] = tx | byte(>>6)&maskx
[3] = tx | byte()&maskx
return 4
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin 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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |