package uniseg// The Unicode properties as used in the various parsers. Only the ones needed// in the context of this package are included.const ( prXX = 0// Same as prAny. prAny = iota// prAny must be 0. prPrepend // Grapheme properties must come first, to reduce the number of bits stored in the state vector. prCR prLF prControl prExtend prRegionalIndicator prSpacingMark prL prV prT prLV prLVT prZWJ prExtendedPictographic prNewline prWSegSpace prDoubleQuote prSingleQuote prMidNumLet prNumeric prMidLetter prMidNum prExtendNumLet prALetter prFormat prHebrewLetter prKatakana prSp prSTerm prClose prSContinue prATerm prUpper prLower prSep prOLetter prCM prBA prBK prSP prEX prQU prAL prPR prPO prOP prCP prIS prHY prSY prNU prCL prNL prGL prAI prBB prHL prSA prJL prJV prJT prNS prZW prB2 prIN prWJ prID prEB prCJ prH2 prH3 prSG prCB prRI prEM prN prNa prA prW prH prF prEmojiPresentation)// Unicode General Categories. Only the ones needed in the context of this// package are included.const ( gcNone = iota// gcNone must be 0. gcCc gcZs gcPo gcSc gcPs gcPe gcSm gcPd gcNd gcLu gcSk gcPc gcLl gcSo gcLo gcPi gcCf gcNo gcPf gcLC gcLm gcMn gcMe gcMc gcNl gcZl gcZp gcCn gcCs gcCo)// Special code points.const ( vs15 = 0xfe0e// Variation Selector-15 (text presentation) vs16 = 0xfe0f// Variation Selector-16 (emoji presentation))// propertySearch performs a binary search on a property slice and returns the// entry whose range (start = first array element, end = second array element)// includes r, or an array of 0's if no such entry was found.func propertySearch[ interface{ [3]int | [4]int }]( [], rune) ( ) {// Run a binary search. := 0 := len()for > { := ( + ) / 2 := []ifint() < [0] { = continue }ifint() > [1] { = + 1continue }return }return}// property returns the Unicode property value (see constants above) of the// given code point.func property( [][3]int, rune) int {returnpropertySearch(, )[2]}// propertyLineBreak returns the Unicode property value and General Category// (see constants above) of the given code point, as listed in the line break// code points table, while fast tracking ASCII digits and letters.func propertyLineBreak( rune) (, int) {if >= 'a' && <= 'z' {returnprAL, gcLl }if >= 'A' && <= 'Z' {returnprAL, gcLu }if >= '0' && <= '9' {returnprNU, gcNd } := propertySearch(lineBreakCodePoints, )return [2], [3]}// propertyGraphemes returns the Unicode grapheme cluster property value of the// given code point while fast tracking ASCII characters.func propertyGraphemes( rune) int {if >= 0x20 && <= 0x7e {returnprAny }if == 0x0a {returnprLF }if == 0x0d {returnprCR }if >= 0 && <= 0x1f || == 0x7f {returnprControl }returnproperty(graphemeCodePoints, )}// propertyEastAsianWidth returns the Unicode East Asian Width property value of// the given code point while fast tracking ASCII characters.func propertyEastAsianWidth( rune) int {if >= 0x20 && <= 0x7e {returnprNa }if >= 0 && <= 0x1f || == 0x7f {returnprN }returnproperty(eastAsianWidth, )}
The pages are generated with Goldsv0.8.2. (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.