Source File
forminfo.go
Belonging Package
vendor/golang.org/x/text/unicode/norm
package norm
import
const (
qcInfoMask = 0x3F // to clear all but the relevant bits in a qcInfo
headerLenMask = 0x3F // extract the length value from the header byte
headerFlagsMask = 0xC0 // extract the qcInfo bits from the header byte
)
type Properties struct {
pos uint8 // start position in reorderBuffer; used in composition.go
size uint8 // length of UTF-8 encoding of this rune
ccc uint8 // leading canonical combining class (ccc if not decomposition)
tccc uint8 // trailing canonical combining class (ccc if not decomposition)
nLead uint8 // number of leading non-starters.
flags qcInfo // quick check flags
index uint16
}
type lookupFunc func(b input, i int) Properties
type formInfo struct {
form Form
composing, compatibility bool // form type
info lookupFunc
nextMain iterFunc
}
var formTable = []*formInfo{{
form: NFC,
composing: true,
compatibility: false,
info: lookupInfoNFC,
nextMain: nextComposed,
}, {
form: NFD,
composing: false,
compatibility: false,
info: lookupInfoNFC,
nextMain: nextDecomposed,
}, {
form: NFKC,
composing: true,
compatibility: true,
info: lookupInfoNFKC,
nextMain: nextComposed,
}, {
form: NFKD,
composing: false,
compatibility: true,
info: lookupInfoNFKC,
nextMain: nextDecomposed,
}}
func ( Properties) () bool {
if .ccc == 0 && !.combinesBackward() {
return true
return false
}
return .isInert()
}
type qcInfo uint8
func ( Properties) () bool { return .flags&0x10 == 0 }
func ( Properties) () bool { return .flags&0x4 == 0 }
func ( Properties) () bool { return .flags&0x20 != 0 }
func ( Properties) () bool { return .flags&0x8 != 0 } // == isMaybe
func ( Properties) () bool { return .flags&0x4 != 0 } // == isNoD
func ( Properties) () bool {
return .flags&qcInfoMask == 0 && .ccc == 0
}
func ( Properties) () bool {
return .index >= firstMulti && .index < endMulti
}
func ( Properties) () uint8 {
return .nLead
}
func ( Properties) () uint8 {
return uint8(.flags & 0x03)
}
func ( Properties) () int {
return int(.size)
}
func ( Properties) () uint8 {
if .index >= firstCCCZeroExcept {
return 0
}
return ccc[.ccc]
}
func ( Properties) () uint8 {
return ccc[.ccc]
}
func (, rune) rune {
:= uint32(uint16())<<16 + uint32(uint16())
if recompMap == nil {
panic("caller error") // see func comment
}
return recompMap[]
}
func ( input, int) Properties {
, := .charinfoNFC()
return compInfo(, )
}
func ( input, int) Properties {
, := .charinfoNFKC()
return compInfo(, )
}
func ( Form) ( string) Properties {
if == NFC || == NFD {
return compInfo(nfcData.lookupString())
}
return compInfo(nfkcData.lookupString())
}
func ( uint16, int) Properties {
if == 0 {
return Properties{size: uint8()}
} else if >= 0x8000 {
:= Properties{
size: uint8(),
ccc: uint8(),
tccc: uint8(),
flags: qcInfo( >> 8),
}
if .ccc > 0 || .combinesBackward() {
.nLead = uint8(.flags & 0x3)
}
return
:= decomps[]
:= (qcInfo(&headerFlagsMask) >> 2) | 0x4
:= Properties{size: uint8(), flags: , index: }
if >= firstCCC {
+= uint16(&headerLenMask) + 1
:= decomps[]
.tccc = >> 2
.flags |= qcInfo( & 0x3)
if >= firstLeadingCCC {
.nLead = & 0x3
![]() |
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. |