Source File
prop.go
Belonging Package
vendor/golang.org/x/text/unicode/bidi
package bidi
import
type Properties struct {
entry uint8
last uint8
}
var trie = newBidiTrie(0)
func ( Properties) () Class {
:= Class(.entry & 0x0F)
if == Control {
= controlByteToClass[.last&0xF]
}
return
}
func ( Properties) () bool { return .entry&0xF0 != 0 }
func ( Properties) () bool { return .entry&openMask != 0 }
func ( Properties) ( rune) rune {
return xorMasks[.entry>>xorMaskShift] ^
}
var controlByteToClass = [16]Class{
0xD: LRO, // U+202D LeftToRightOverride,
0xE: RLO, // U+202E RightToLeftOverride,
0xA: LRE, // U+202A LeftToRightEmbedding,
0xB: RLE, // U+202B RightToLeftEmbedding,
0xC: PDF, // U+202C PopDirectionalFormat,
0x6: LRI, // U+2066 LeftToRightIsolate,
0x7: RLI, // U+2067 RightToLeftIsolate,
0x8: FSI, // U+2068 FirstStrongIsolate,
0x9: PDI, // U+2069 PopDirectionalIsolate,
}
func ( rune) ( Properties, int) {
var [4]byte
:= utf8.EncodeRune([:], )
return Lookup([:])
}
func ( []byte) ( Properties, int) {
:= [0]
switch {
case < 0x80: // is ASCII
return Properties{entry: bidiValues[]}, 1
case < 0xC2:
return Properties{}, 1
case < 0xE0: // 2-byte UTF-8
if len() < 2 {
return Properties{}, 0
}
:= bidiIndex[]
:= [1]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(), )}, 2
case < 0xF0: // 3-byte UTF-8
if len() < 3 {
return Properties{}, 0
}
:= bidiIndex[]
:= [1]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
:= uint32()<<6 + uint32()
= bidiIndex[]
:= [2]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(), ), last: }, 3
case < 0xF8: // 4-byte UTF-8
if len() < 4 {
return Properties{}, 0
}
:= bidiIndex[]
:= [1]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
:= uint32()<<6 + uint32()
= bidiIndex[]
:= [2]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
= uint32()<<6 + uint32()
= bidiIndex[]
:= [3]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(), )}, 4
return Properties{}, 1
}
func ( string) ( Properties, int) {
:= [0]
switch {
case < 0x80: // is ASCII
return Properties{entry: bidiValues[]}, 1
case < 0xC2:
return Properties{}, 1
case < 0xE0: // 2-byte UTF-8
if len() < 2 {
return Properties{}, 0
}
:= bidiIndex[]
:= [1]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(), )}, 2
case < 0xF0: // 3-byte UTF-8
if len() < 3 {
return Properties{}, 0
}
:= bidiIndex[]
:= [1]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
:= uint32()<<6 + uint32()
= bidiIndex[]
:= [2]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(), ), last: }, 3
case < 0xF8: // 4-byte UTF-8
if len() < 4 {
return Properties{}, 0
}
:= bidiIndex[]
:= [1]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
:= uint32()<<6 + uint32()
= bidiIndex[]
:= [2]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
= uint32()<<6 + uint32()
= bidiIndex[]
:= [3]
if < 0x80 || 0xC0 <= {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(), )}, 4
return Properties{}, 1
![]() |
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. |