code
stringlengths 11
335k
| docstring
stringlengths 20
11.8k
| func_name
stringlengths 1
100
| language
stringclasses 1
value | repo
stringclasses 245
values | path
stringlengths 4
144
| url
stringlengths 43
214
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
func (r *Run) Bytes() []byte {
panic("unimplemented")
} | Bytes returns the text of the run in its original order. | Bytes | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/bidi.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/bidi.go | BSD-3-Clause |
func (r *Run) Direction() Direction {
panic("unimplemented")
} | Direction reports the direction of the run. | Direction | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/bidi.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/bidi.go | BSD-3-Clause |
func (r *Run) Pos() (start, end int) {
panic("unimplemented")
} | Position of the Run within the text passed to SetBytes or SetString of the
originating Paragraph value. | Pos | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/bidi.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/bidi.go | BSD-3-Clause |
func AppendReverse(out, in []byte) []byte {
panic("unimplemented")
} | AppendReverse reverses the order of characters of in, appends them to out,
and returns the result. Modifiers will still follow the runes they modify.
Brackets are replaced with their counterparts. | AppendReverse | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/bidi.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/bidi.go | BSD-3-Clause |
func ReverseString(s string) string {
panic("unimplemented")
} | ReverseString reverses the order of characters in s and returns a new string.
Modifiers will still follow the runes they modify. Brackets are replaced with
their counterparts. | ReverseString | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/bidi.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/bidi.go | BSD-3-Clause |
func (t *bidiTrie) lookup(s []byte) (v uint8, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return bidiValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookup returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupUnsafe(s []byte) uint8 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return bidiValues[c0]
}
i := bidiIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = bidiIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = bidiIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupString(s string) (v uint8, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return bidiValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookupString returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupStringUnsafe(s string) uint8 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return bidiValues[c0]
}
i := bidiIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = bidiIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = bidiIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupStringUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupValue(n uint32, b byte) uint8 {
switch {
default:
return uint8(bidiValues[n<<6+uint32(b)])
}
} | lookupValue determines the type of block n and looks up the value for b. | lookupValue | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookup(s []byte) (v uint8, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return bidiValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookup returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupUnsafe(s []byte) uint8 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return bidiValues[c0]
}
i := bidiIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = bidiIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = bidiIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupString(s string) (v uint8, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return bidiValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookupString returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupStringUnsafe(s string) uint8 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return bidiValues[c0]
}
i := bidiIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = bidiIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = bidiIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupStringUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupValue(n uint32, b byte) uint8 {
switch {
default:
return uint8(bidiValues[n<<6+uint32(b)])
}
} | lookupValue determines the type of block n and looks up the value for b. | lookupValue | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookup(s []byte) (v uint8, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return bidiValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookup returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupUnsafe(s []byte) uint8 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return bidiValues[c0]
}
i := bidiIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = bidiIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = bidiIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupString(s string) (v uint8, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return bidiValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookupString returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupStringUnsafe(s string) uint8 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return bidiValues[c0]
}
i := bidiIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = bidiIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = bidiIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupStringUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | BSD-3-Clause |
func (t *bidiTrie) lookupValue(n uint32, b byte) uint8 {
switch {
default:
return uint8(bidiValues[n<<6+uint32(b)])
}
} | lookupValue determines the type of block n and looks up the value for b. | lookupValue | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go | BSD-3-Clause |
func (p Properties) Class() Class {
c := Class(p.entry & 0x0F)
if c == Control {
c = controlByteToClass[p.last&0xF]
}
return c
} | Class returns the Bidi class for p. | Class | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/prop.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/prop.go | BSD-3-Clause |
func (p Properties) IsBracket() bool { return p.entry&0xF0 != 0 } | IsBracket reports whether the rune is a bracket. | IsBracket | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/prop.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/prop.go | BSD-3-Clause |
func (p Properties) IsOpeningBracket() bool { return p.entry&openMask != 0 } | IsOpeningBracket reports whether the rune is an opening bracket.
IsBracket must return true. | IsOpeningBracket | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/prop.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/prop.go | BSD-3-Clause |
func LookupRune(r rune) (p Properties, size int) {
var buf [4]byte
n := utf8.EncodeRune(buf[:], r)
return Lookup(buf[:n])
} | LookupRune returns properties for r. | LookupRune | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/prop.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/prop.go | BSD-3-Clause |
func Lookup(s []byte) (p Properties, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return Properties{entry: bidiValues[c0]}, 1
case c0 < 0xC2:
return Properties{}, 1
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return Properties{}, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(i), c1)}, 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return Properties{}, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return Properties{}, 1
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(i), c2), last: c2}, 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return Properties{}, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return Properties{}, 1
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return Properties{}, 1
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(i), c3)}, 4
}
// Illegal rune
return Properties{}, 1
} | Lookup returns properties for the first rune in s and the width in bytes of
its encoding. The size will be 0 if s does not hold enough bytes to complete
the encoding. | Lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/prop.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/prop.go | BSD-3-Clause |
func LookupString(s string) (p Properties, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return Properties{entry: bidiValues[c0]}, 1
case c0 < 0xC2:
return Properties{}, 1
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return Properties{}, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(i), c1)}, 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return Properties{}, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return Properties{}, 1
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(i), c2), last: c2}, 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return Properties{}, 0
}
i := bidiIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return Properties{}, 1
}
o := uint32(i)<<6 + uint32(c1)
i = bidiIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return Properties{}, 1
}
o = uint32(i)<<6 + uint32(c2)
i = bidiIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return Properties{}, 1
}
return Properties{entry: trie.lookupValue(uint32(i), c3)}, 4
}
// Illegal rune
return Properties{}, 1
} | LookupString returns properties for the first rune in s and the width in
bytes of its encoding. The size will be 0 if s does not hold enough bytes to
complete the encoding. | LookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/bidi/prop.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/bidi/prop.go | BSD-3-Clause |
func (t *sparseBlocks) lookup(n uint32, b byte) uint16 {
offset := t.offset[n]
header := t.values[offset]
lo := offset + 1
hi := lo + uint16(header.lo)
for lo < hi {
m := lo + (hi-lo)/2
r := t.values[m]
if r.lo <= b && b <= r.hi {
return r.value + uint16(b-r.lo)*header.value
}
if b < r.lo {
hi = m
} else {
lo = m + 1
}
}
return 0
} | lookupValue determines the type of block n and looks up the value for b.
For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
is a list of ranges with an accompanying value. Given a matching range r,
the value for b is by r.value + (b - r.lo) * stride. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/trie.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/trie.go | BSD-3-Clause |
func (p Properties) BoundaryBefore() bool {
if p.ccc == 0 && !p.combinesBackward() {
return true
}
// We assume that the CCC of the first character in a decomposition
// is always non-zero if different from info.ccc and that we can return
// false at this point. This is verified by maketables.
return false
} | BoundaryBefore returns true if this rune starts a new segment and
cannot combine with any rune on the left. | BoundaryBefore | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (p Properties) BoundaryAfter() bool {
// TODO: loosen these conditions.
return p.isInert()
} | BoundaryAfter returns true if runes cannot combine with or otherwise
interact with this or previous runes. | BoundaryAfter | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (p Properties) Decomposition() []byte {
// TODO: create the decomposition for Hangul?
if p.index == 0 {
return nil
}
i := p.index
n := decomps[i] & headerLenMask
i++
return decomps[i : i+uint16(n)]
} | Decomposition returns the decomposition for the underlying rune
or nil if there is none. | Decomposition | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (p Properties) Size() int {
return int(p.size)
} | Size returns the length of UTF-8 encoding of the rune. | Size | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (p Properties) CCC() uint8 {
if p.index >= firstCCCZeroExcept {
return 0
}
return ccc[p.ccc]
} | CCC returns the canonical combining class of the underlying rune. | CCC | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (p Properties) LeadCCC() uint8 {
return ccc[p.ccc]
} | LeadCCC returns the CCC of the first rune in the decomposition.
If there is no decomposition, LeadCCC equals CCC. | LeadCCC | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (p Properties) TrailCCC() uint8 {
return ccc[p.tccc]
} | TrailCCC returns the CCC of the last rune in the decomposition.
If there is no decomposition, TrailCCC equals CCC. | TrailCCC | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func combine(a, b rune) rune {
key := uint32(uint16(a))<<16 + uint32(uint16(b))
if recompMap == nil {
panic("caller error") // see func comment
}
return recompMap[key]
} | combine returns the combined rune or 0 if it doesn't exist.
The caller is responsible for calling
recompMapOnce.Do(buildRecompMap) sometime before this is called. | combine | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (f Form) Properties(s []byte) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookup(s))
}
return compInfo(nfkcData.lookup(s))
} | Properties returns properties for the first rune in s. | Properties | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (f Form) PropertiesString(s string) Properties {
if f == NFC || f == NFD {
return compInfo(nfcData.lookupString(s))
}
return compInfo(nfkcData.lookupString(s))
} | PropertiesString returns properties for the first rune in s. | PropertiesString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func compInfo(v uint16, sz int) Properties {
if v == 0 {
return Properties{size: uint8(sz)}
} else if v >= 0x8000 {
p := Properties{
size: uint8(sz),
ccc: uint8(v),
tccc: uint8(v),
flags: qcInfo(v >> 8),
}
if p.ccc > 0 || p.combinesBackward() {
p.nLead = uint8(p.flags & 0x3)
}
return p
}
// has decomposition
h := decomps[v]
f := (qcInfo(h&headerFlagsMask) >> 2) | 0x4
p := Properties{size: uint8(sz), flags: f, index: v}
if v >= firstCCC {
v += uint16(h&headerLenMask) + 1
c := decomps[v]
p.tccc = c >> 2
p.flags |= qcInfo(c & 0x3)
if v >= firstLeadingCCC {
p.nLead = c & 0x3
if v >= firstStarterWithNLead {
// We were tricked. Remove the decomposition.
p.flags &= 0x03
p.index = 0
return p
}
p.ccc = decomps[v+1]
}
}
return p
} | compInfo converts the information contained in v and sz
to a Properties. See the comment at the top of the file
for more information on the format. | compInfo | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/forminfo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/forminfo.go | BSD-3-Clause |
func (ss *streamSafe) first(p Properties) {
*ss = streamSafe(p.nTrailingNonStarters())
} | first inserts the first rune of a segment. It is a faster version of next if
it is known p represents the first rune in a segment. | first | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (ss *streamSafe) next(p Properties) ssState {
if *ss > maxNonStarters {
panic("streamSafe was not reset")
}
n := p.nLeadingNonStarters()
if *ss += streamSafe(n); *ss > maxNonStarters {
*ss = 0
return ssOverflow
}
// The Stream-Safe Text Processing prescribes that the counting can stop
// as soon as a starter is encountered. However, there are some starters,
// like Jamo V and T, that can combine with other runes, leaving their
// successive non-starters appended to the previous, possibly causing an
// overflow. We will therefore consider any rune with a non-zero nLead to
// be a non-starter. Note that it always hold that if nLead > 0 then
// nLead == nTrail.
if n == 0 {
*ss = streamSafe(p.nTrailingNonStarters())
return ssStarter
}
return ssSuccess
} | insert returns a ssState value to indicate whether a rune represented by p
can be inserted. | next | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (ss *streamSafe) backwards(p Properties) ssState {
if *ss > maxNonStarters {
panic("streamSafe was not reset")
}
c := *ss + streamSafe(p.nTrailingNonStarters())
if c > maxNonStarters {
return ssOverflow
}
*ss = c
if p.nLeadingNonStarters() == 0 {
return ssStarter
}
return ssSuccess
} | backwards is used for checking for overflow and segment starts
when traversing a string backwards. Users do not need to call first
for the first rune. The state of the streamSafe retains the count of
the non-starters loaded. | backwards | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) reset() {
rb.nrune = 0
rb.nbyte = 0
} | reset discards all characters from the buffer. | reset | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func appendFlush(rb *reorderBuffer) bool {
for i := 0; i < rb.nrune; i++ {
start := rb.rune[i].pos
end := start + rb.rune[i].size
rb.out = append(rb.out, rb.byte[start:end]...)
}
return true
} | appendFlush appends the normalized segment to rb.out. | appendFlush | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) flush(out []byte) []byte {
for i := 0; i < rb.nrune; i++ {
start := rb.rune[i].pos
end := start + rb.rune[i].size
out = append(out, rb.byte[start:end]...)
}
rb.reset()
return out
} | flush appends the normalized segment to out and resets rb. | flush | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) flushCopy(buf []byte) int {
p := 0
for i := 0; i < rb.nrune; i++ {
runep := rb.rune[i]
p += copy(buf[p:], rb.byte[runep.pos:runep.pos+runep.size])
}
rb.reset()
return p
} | flushCopy copies the normalized segment to buf and resets rb.
It returns the number of bytes written to buf. | flushCopy | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) insertOrdered(info Properties) {
n := rb.nrune
b := rb.rune[:]
cc := info.ccc
if cc > 0 {
// Find insertion position + move elements to make room.
for ; n > 0; n-- {
if b[n-1].ccc <= cc {
break
}
b[n] = b[n-1]
}
}
rb.nrune += 1
pos := uint8(rb.nbyte)
rb.nbyte += utf8.UTFMax
info.pos = pos
b[n] = info
} | insertOrdered inserts a rune in the buffer, ordered by Canonical Combining Class.
It returns false if the buffer is not large enough to hold the rune.
It is used internally by insert and insertString only. | insertOrdered | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) insertFlush(src input, i int, info Properties) insertErr {
if rune := src.hangul(i); rune != 0 {
rb.decomposeHangul(rune)
return iSuccess
}
if info.hasDecomposition() {
return rb.insertDecomposed(info.Decomposition())
}
rb.insertSingle(src, i, info)
return iSuccess
} | insertFlush inserts the given rune in the buffer ordered by CCC.
If a decomposition with multiple segments are encountered, they leading
ones are flushed.
It returns a non-zero error code if the rune was not inserted. | insertFlush | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) insertUnsafe(src input, i int, info Properties) {
if rune := src.hangul(i); rune != 0 {
rb.decomposeHangul(rune)
}
if info.hasDecomposition() {
// TODO: inline.
rb.insertDecomposed(info.Decomposition())
} else {
rb.insertSingle(src, i, info)
}
} | insertUnsafe inserts the given rune in the buffer ordered by CCC.
It is assumed there is sufficient space to hold the runes. It is the
responsibility of the caller to ensure this. This can be done by checking
the state returned by the streamSafe type. | insertUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) insertDecomposed(dcomp []byte) insertErr {
rb.tmpBytes.setBytes(dcomp)
// As the streamSafe accounting already handles the counting for modifiers,
// we don't have to call next. However, we do need to keep the accounting
// intact when flushing the buffer.
for i := 0; i < len(dcomp); {
info := rb.f.info(rb.tmpBytes, i)
if info.BoundaryBefore() && rb.nrune > 0 && !rb.doFlush() {
return iShortDst
}
i += copy(rb.byte[rb.nbyte:], dcomp[i:i+int(info.size)])
rb.insertOrdered(info)
}
return iSuccess
} | insertDecomposed inserts an entry in to the reorderBuffer for each rune
in dcomp. dcomp must be a sequence of decomposed UTF-8-encoded runes.
It flushes the buffer on each new segment start. | insertDecomposed | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) insertSingle(src input, i int, info Properties) {
src.copySlice(rb.byte[rb.nbyte:], i, i+int(info.size))
rb.insertOrdered(info)
} | insertSingle inserts an entry in the reorderBuffer for the rune at
position i. info is the runeInfo for the rune at position i. | insertSingle | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) insertCGJ() {
rb.insertSingle(input{str: GraphemeJoiner}, 0, Properties{size: uint8(len(GraphemeJoiner))})
} | insertCGJ inserts a Combining Grapheme Joiner (0x034f) into rb. | insertCGJ | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) appendRune(r rune) {
bn := rb.nbyte
sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.nbyte += utf8.UTFMax
rb.rune[rb.nrune] = Properties{pos: bn, size: uint8(sz)}
rb.nrune++
} | appendRune inserts a rune at the end of the buffer. It is used for Hangul. | appendRune | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) assignRune(pos int, r rune) {
bn := rb.rune[pos].pos
sz := utf8.EncodeRune(rb.byte[bn:], rune(r))
rb.rune[pos] = Properties{pos: bn, size: uint8(sz)}
} | assignRune sets a rune at position pos. It is used for Hangul and recomposition. | assignRune | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) runeAt(n int) rune {
inf := rb.rune[n]
r, _ := utf8.DecodeRune(rb.byte[inf.pos : inf.pos+inf.size])
return r
} | runeAt returns the rune at position n. It is used for Hangul and recomposition. | runeAt | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) bytesAt(n int) []byte {
inf := rb.rune[n]
return rb.byte[inf.pos : int(inf.pos)+int(inf.size)]
} | bytesAt returns the UTF-8 encoding of the rune at position n.
It is used for Hangul and recomposition. | bytesAt | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func isJamoVT(b []byte) bool {
// True if (rune & 0xff00) == jamoLBase
return b[0] == jamoLBase0 && (b[1]&0xFC) == jamoLBase1
} | Caller must ensure len(b) >= 2. | isJamoVT | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func decomposeHangul(buf []byte, r rune) int {
const JamoUTF8Len = 3
r -= hangulBase
x := r % jamoTCount
r /= jamoTCount
utf8.EncodeRune(buf, jamoLBase+r/jamoVCount)
utf8.EncodeRune(buf[JamoUTF8Len:], jamoVBase+r%jamoVCount)
if x != 0 {
utf8.EncodeRune(buf[2*JamoUTF8Len:], jamoTBase+x)
return 3 * JamoUTF8Len
}
return 2 * JamoUTF8Len
} | decomposeHangul writes the decomposed Hangul to buf and returns the number
of bytes written. len(buf) should be at least 9. | decomposeHangul | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) decomposeHangul(r rune) {
r -= hangulBase
x := r % jamoTCount
r /= jamoTCount
rb.appendRune(jamoLBase + r/jamoVCount)
rb.appendRune(jamoVBase + r%jamoVCount)
if x != 0 {
rb.appendRune(jamoTBase + x)
}
} | decomposeHangul algorithmically decomposes a Hangul rune into
its Jamo components.
See https://unicode.org/reports/tr15/#Hangul for details on decomposing Hangul. | decomposeHangul | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) combineHangul(s, i, k int) {
b := rb.rune[:]
bn := rb.nrune
for ; i < bn; i++ {
cccB := b[k-1].ccc
cccC := b[i].ccc
if cccB == 0 {
s = k - 1
}
if s != k-1 && cccB >= cccC {
// b[i] is blocked by greater-equal cccX below it
b[k] = b[i]
k++
} else {
l := rb.runeAt(s) // also used to compare to hangulBase
v := rb.runeAt(i) // also used to compare to jamoT
switch {
case jamoLBase <= l && l < jamoLEnd &&
jamoVBase <= v && v < jamoVEnd:
// 11xx plus 116x to LV
rb.assignRune(s, hangulBase+
(l-jamoLBase)*jamoVTCount+(v-jamoVBase)*jamoTCount)
case hangulBase <= l && l < hangulEnd &&
jamoTBase < v && v < jamoTEnd &&
((l-hangulBase)%jamoTCount) == 0:
// ACxx plus 11Ax to LVT
rb.assignRune(s, l+v-jamoTBase)
default:
b[k] = b[i]
k++
}
}
}
rb.nrune = k
} | combineHangul algorithmically combines Jamo character components into Hangul.
See https://unicode.org/reports/tr15/#Hangul for details on combining Hangul. | combineHangul | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (rb *reorderBuffer) compose() {
// Lazily load the map used by the combine func below, but do
// it outside of the loop.
recompMapOnce.Do(buildRecompMap)
// UAX #15, section X5 , including Corrigendum #5
// "In any character sequence beginning with starter S, a character C is
// blocked from S if and only if there is some character B between S
// and C, and either B is a starter or it has the same or higher
// combining class as C."
bn := rb.nrune
if bn == 0 {
return
}
k := 1
b := rb.rune[:]
for s, i := 0, 1; i < bn; i++ {
if isJamoVT(rb.bytesAt(i)) {
// Redo from start in Hangul mode. Necessary to support
// U+320E..U+321E in NFKC mode.
rb.combineHangul(s, i, k)
return
}
ii := b[i]
// We can only use combineForward as a filter if we later
// get the info for the combined character. This is more
// expensive than using the filter. Using combinesBackward()
// is safe.
if ii.combinesBackward() {
cccB := b[k-1].ccc
cccC := ii.ccc
blocked := false // b[i] blocked by starter or greater or equal CCC?
if cccB == 0 {
s = k - 1
} else {
blocked = s != k-1 && cccB >= cccC
}
if !blocked {
combined := combine(rb.runeAt(s), rb.runeAt(i))
if combined != 0 {
rb.assignRune(s, combined)
continue
}
}
}
b[k] = b[i]
k++
}
rb.nrune = k
} | compose recombines the runes in the buffer.
It should only be used to recompose a single segment, as it will not
handle alternations between Hangul and non-Hangul characters correctly. | compose | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/composition.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/composition.go | BSD-3-Clause |
func (f Form) Bytes(b []byte) []byte {
src := inputBytes(b)
ft := formTable[f]
n, ok := ft.quickSpan(src, 0, len(b), true)
if ok {
return b
}
out := make([]byte, n, len(b))
copy(out, b[0:n])
rb := reorderBuffer{f: *ft, src: src, nsrc: len(b), out: out, flushF: appendFlush}
return doAppendInner(&rb, n)
} | Bytes returns f(b). May return b if f(b) = b. | Bytes | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) String(s string) string {
src := inputString(s)
ft := formTable[f]
n, ok := ft.quickSpan(src, 0, len(s), true)
if ok {
return s
}
out := make([]byte, n, len(s))
copy(out, s[0:n])
rb := reorderBuffer{f: *ft, src: src, nsrc: len(s), out: out, flushF: appendFlush}
return string(doAppendInner(&rb, n))
} | String returns f(s). | String | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) IsNormal(b []byte) bool {
src := inputBytes(b)
ft := formTable[f]
bp, ok := ft.quickSpan(src, 0, len(b), true)
if ok {
return true
}
rb := reorderBuffer{f: *ft, src: src, nsrc: len(b)}
rb.setFlusher(nil, cmpNormalBytes)
for bp < len(b) {
rb.out = b[bp:]
if bp = decomposeSegment(&rb, bp, true); bp < 0 {
return false
}
bp, _ = rb.f.quickSpan(rb.src, bp, len(b), true)
}
return true
} | IsNormal returns true if b == f(b). | IsNormal | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) IsNormalString(s string) bool {
src := inputString(s)
ft := formTable[f]
bp, ok := ft.quickSpan(src, 0, len(s), true)
if ok {
return true
}
rb := reorderBuffer{f: *ft, src: src, nsrc: len(s)}
rb.setFlusher(nil, func(rb *reorderBuffer) bool {
for i := 0; i < rb.nrune; i++ {
info := rb.rune[i]
if bp+int(info.size) > len(s) {
return false
}
p := info.pos
pe := p + info.size
for ; p < pe; p++ {
if s[bp] != rb.byte[p] {
return false
}
bp++
}
}
return true
})
for bp < len(s) {
if bp = decomposeSegment(&rb, bp, true); bp < 0 {
return false
}
bp, _ = rb.f.quickSpan(rb.src, bp, len(s), true)
}
return true
} | IsNormalString returns true if s == f(s). | IsNormalString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func patchTail(rb *reorderBuffer) bool {
info, p := lastRuneStart(&rb.f, rb.out)
if p == -1 || info.size == 0 {
return true
}
end := p + int(info.size)
extra := len(rb.out) - end
if extra > 0 {
// Potentially allocating memory. However, this only
// happens with ill-formed UTF-8.
x := make([]byte, 0)
x = append(x, rb.out[len(rb.out)-extra:]...)
rb.out = rb.out[:end]
decomposeToLastBoundary(rb)
rb.doFlush()
rb.out = append(rb.out, x...)
return false
}
buf := rb.out[p:]
rb.out = rb.out[:p]
decomposeToLastBoundary(rb)
if s := rb.ss.next(info); s == ssStarter {
rb.doFlush()
rb.ss.first(info)
} else if s == ssOverflow {
rb.doFlush()
rb.insertCGJ()
rb.ss = 0
}
rb.insertUnsafe(inputBytes(buf), 0, info)
return true
} | patchTail fixes a case where a rune may be incorrectly normalized
if it is followed by illegal continuation bytes. It returns the
patched buffer and whether the decomposition is still in progress. | patchTail | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) Append(out []byte, src ...byte) []byte {
return f.doAppend(out, inputBytes(src), len(src))
} | Append returns f(append(out, b...)).
The buffer out must be nil, empty, or equal to f(out). | Append | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) AppendString(out []byte, src string) []byte {
return f.doAppend(out, inputString(src), len(src))
} | AppendString returns f(append(out, []byte(s))).
The buffer out must be nil, empty, or equal to f(out). | AppendString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) QuickSpan(b []byte) int {
n, _ := formTable[f].quickSpan(inputBytes(b), 0, len(b), true)
return n
} | QuickSpan returns a boundary n such that b[0:n] == f(b[0:n]).
It is not guaranteed to return the largest such n. | QuickSpan | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) Span(b []byte, atEOF bool) (n int, err error) {
n, ok := formTable[f].quickSpan(inputBytes(b), 0, len(b), atEOF)
if n < len(b) {
if !ok {
err = transform.ErrEndOfSpan
} else {
err = transform.ErrShortSrc
}
}
return n, err
} | Span implements transform.SpanningTransformer. It returns a boundary n such
that b[0:n] == f(b[0:n]). It is not guaranteed to return the largest such n. | Span | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) SpanString(s string, atEOF bool) (n int, err error) {
n, ok := formTable[f].quickSpan(inputString(s), 0, len(s), atEOF)
if n < len(s) {
if !ok {
err = transform.ErrEndOfSpan
} else {
err = transform.ErrShortSrc
}
}
return n, err
} | SpanString returns a boundary n such that s[0:n] == f(s[0:n]).
It is not guaranteed to return the largest such n. | SpanString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f *formInfo) quickSpan(src input, i, end int, atEOF bool) (n int, ok bool) {
var lastCC uint8
ss := streamSafe(0)
lastSegStart := i
for n = end; i < n; {
if j := src.skipASCII(i, n); i != j {
i = j
lastSegStart = i - 1
lastCC = 0
ss = 0
continue
}
info := f.info(src, i)
if info.size == 0 {
if atEOF {
// include incomplete runes
return n, true
}
return lastSegStart, true
}
// This block needs to be before the next, because it is possible to
// have an overflow for runes that are starters (e.g. with U+FF9E).
switch ss.next(info) {
case ssStarter:
lastSegStart = i
case ssOverflow:
return lastSegStart, false
case ssSuccess:
if lastCC > info.ccc {
return lastSegStart, false
}
}
if f.composing {
if !info.isYesC() {
break
}
} else {
if !info.isYesD() {
break
}
}
lastCC = info.ccc
i += int(info.size)
}
if i == n {
if !atEOF {
n = lastSegStart
}
return n, true
}
return lastSegStart, false
} | quickSpan returns a boundary n such that src[0:n] == f(src[0:n]) and
whether any non-normalized parts were found. If atEOF is false, n will
not point past the last segment if this segment might be become
non-normalized by appending other runes. | quickSpan | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) QuickSpanString(s string) int {
n, _ := formTable[f].quickSpan(inputString(s), 0, len(s), true)
return n
} | QuickSpanString returns a boundary n such that s[0:n] == f(s[0:n]).
It is not guaranteed to return the largest such n. | QuickSpanString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) FirstBoundary(b []byte) int {
return f.firstBoundary(inputBytes(b), len(b))
} | FirstBoundary returns the position i of the first boundary in b
or -1 if b contains no boundary. | FirstBoundary | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) FirstBoundaryInString(s string) int {
return f.firstBoundary(inputString(s), len(s))
} | FirstBoundaryInString returns the position i of the first boundary in s
or -1 if s contains no boundary. | FirstBoundaryInString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) NextBoundary(b []byte, atEOF bool) int {
return f.nextBoundary(inputBytes(b), len(b), atEOF)
} | NextBoundary reports the index of the boundary between the first and next
segment in b or -1 if atEOF is false and there are not enough bytes to
determine this boundary. | NextBoundary | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) NextBoundaryInString(s string, atEOF bool) int {
return f.nextBoundary(inputString(s), len(s), atEOF)
} | NextBoundaryInString reports the index of the boundary between the first and
next segment in b or -1 if atEOF is false and there are not enough bytes to
determine this boundary. | NextBoundaryInString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (f Form) LastBoundary(b []byte) int {
return lastBoundary(formTable[f], b)
} | LastBoundary returns the position i of the last boundary in b
or -1 if b contains no boundary. | LastBoundary | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func decomposeSegment(rb *reorderBuffer, sp int, atEOF bool) int {
// Force one character to be consumed.
info := rb.f.info(rb.src, sp)
if info.size == 0 {
return 0
}
if s := rb.ss.next(info); s == ssStarter {
// TODO: this could be removed if we don't support merging.
if rb.nrune > 0 {
goto end
}
} else if s == ssOverflow {
rb.insertCGJ()
goto end
}
if err := rb.insertFlush(rb.src, sp, info); err != iSuccess {
return int(err)
}
for {
sp += int(info.size)
if sp >= rb.nsrc {
if !atEOF && !info.BoundaryAfter() {
return int(iShortSrc)
}
break
}
info = rb.f.info(rb.src, sp)
if info.size == 0 {
if !atEOF {
return int(iShortSrc)
}
break
}
if s := rb.ss.next(info); s == ssStarter {
break
} else if s == ssOverflow {
rb.insertCGJ()
break
}
if err := rb.insertFlush(rb.src, sp, info); err != iSuccess {
return int(err)
}
}
end:
if !rb.doFlush() {
return int(iShortDst)
}
return sp
} | decomposeSegment scans the first segment in src into rb. It inserts 0x034f
(Grapheme Joiner) when it encounters a sequence of more than 30 non-starters
and returns the number of bytes consumed from src or iShortDst or iShortSrc. | decomposeSegment | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func lastRuneStart(fd *formInfo, buf []byte) (Properties, int) {
p := len(buf) - 1
for ; p >= 0 && !utf8.RuneStart(buf[p]); p-- {
}
if p < 0 {
return Properties{}, -1
}
return fd.info(inputBytes(buf), p), p
} | lastRuneStart returns the runeInfo and position of the last
rune in buf or the zero runeInfo and -1 if no rune was found. | lastRuneStart | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func decomposeToLastBoundary(rb *reorderBuffer) {
fd := &rb.f
info, i := lastRuneStart(fd, rb.out)
if int(info.size) != len(rb.out)-i {
// illegal trailing continuation bytes
return
}
if info.BoundaryAfter() {
return
}
var add [maxNonStarters + 1]Properties // stores runeInfo in reverse order
padd := 0
ss := streamSafe(0)
p := len(rb.out)
for {
add[padd] = info
v := ss.backwards(info)
if v == ssOverflow {
// Note that if we have an overflow, it the string we are appending to
// is not correctly normalized. In this case the behavior is undefined.
break
}
padd++
p -= int(info.size)
if v == ssStarter || p < 0 {
break
}
info, i = lastRuneStart(fd, rb.out[:p])
if int(info.size) != p-i {
break
}
}
rb.ss = ss
// Copy bytes for insertion as we may need to overwrite rb.out.
var buf [maxBufferSize * utf8.UTFMax]byte
cp := buf[:copy(buf[:], rb.out[p:])]
rb.out = rb.out[:p]
for padd--; padd >= 0; padd-- {
info = add[padd]
rb.insertUnsafe(inputBytes(cp), 0, info)
cp = cp[info.size:]
}
} | decomposeToLastBoundary finds an open segment at the end of the buffer
and scans it into rb. Returns the buffer minus the last segment. | decomposeToLastBoundary | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/normalize.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/normalize.go | BSD-3-Clause |
func (t *nfcTrie) lookup(s []byte) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookup returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupUnsafe(s []byte) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfcValues[c0]
}
i := nfcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupString(s string) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookupString returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupStringUnsafe(s string) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfcValues[c0]
}
i := nfcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupStringUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupValue(n uint32, b byte) uint16 {
switch {
case n < 44:
return uint16(nfcValues[n<<6+uint32(b)])
default:
n -= 44
return uint16(nfcSparse.lookup(n, b))
}
} | lookupValue determines the type of block n and looks up the value for b. | lookupValue | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookup(s []byte) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfkcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfkcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookup returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupUnsafe(s []byte) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfkcValues[c0]
}
i := nfkcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupString(s string) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfkcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfkcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookupString returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupStringUnsafe(s string) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfkcValues[c0]
}
i := nfkcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupStringUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupValue(n uint32, b byte) uint16 {
switch {
case n < 90:
return uint16(nfkcValues[n<<6+uint32(b)])
default:
n -= 90
return uint16(nfkcSparse.lookup(n, b))
}
} | lookupValue determines the type of block n and looks up the value for b. | lookupValue | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookup(s []byte) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookup returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupUnsafe(s []byte) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfcValues[c0]
}
i := nfcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupString(s string) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookupString returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupStringUnsafe(s string) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfcValues[c0]
}
i := nfcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupStringUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfcTrie) lookupValue(n uint32, b byte) uint16 {
switch {
case n < 46:
return uint16(nfcValues[n<<6+uint32(b)])
default:
n -= 46
return uint16(nfcSparse.lookup(n, b))
}
} | lookupValue determines the type of block n and looks up the value for b. | lookupValue | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookup(s []byte) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfkcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfkcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookup returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookup | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupUnsafe(s []byte) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfkcValues[c0]
}
i := nfkcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupString(s string) (v uint16, sz int) {
c0 := s[0]
switch {
case c0 < 0x80: // is ASCII
return nfkcValues[c0], 1
case c0 < 0xC2:
return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
case c0 < 0xE0: // 2-byte UTF-8
if len(s) < 2 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c1), 2
case c0 < 0xF0: // 3-byte UTF-8
if len(s) < 3 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c2), 3
case c0 < 0xF8: // 4-byte UTF-8
if len(s) < 4 {
return 0, 0
}
i := nfkcIndex[c0]
c1 := s[1]
if c1 < 0x80 || 0xC0 <= c1 {
return 0, 1 // Illegal UTF-8: not a continuation byte.
}
o := uint32(i)<<6 + uint32(c1)
i = nfkcIndex[o]
c2 := s[2]
if c2 < 0x80 || 0xC0 <= c2 {
return 0, 2 // Illegal UTF-8: not a continuation byte.
}
o = uint32(i)<<6 + uint32(c2)
i = nfkcIndex[o]
c3 := s[3]
if c3 < 0x80 || 0xC0 <= c3 {
return 0, 3 // Illegal UTF-8: not a continuation byte.
}
return t.lookupValue(uint32(i), c3), 4
}
// Illegal rune
return 0, 1
} | lookupString returns the trie value for the first UTF-8 encoding in s and
the width in bytes of this encoding. The size will be 0 if s does not
hold enough bytes to complete the encoding. len(s) must be greater than 0. | lookupString | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupStringUnsafe(s string) uint16 {
c0 := s[0]
if c0 < 0x80 { // is ASCII
return nfkcValues[c0]
}
i := nfkcIndex[c0]
if c0 < 0xE0 { // 2-byte UTF-8
return t.lookupValue(uint32(i), s[1])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[1])]
if c0 < 0xF0 { // 3-byte UTF-8
return t.lookupValue(uint32(i), s[2])
}
i = nfkcIndex[uint32(i)<<6+uint32(s[2])]
if c0 < 0xF8 { // 4-byte UTF-8
return t.lookupValue(uint32(i), s[3])
}
return 0
} | lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s.
s must start with a full and valid UTF-8 encoded rune. | lookupStringUnsafe | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
func (t *nfkcTrie) lookupValue(n uint32, b byte) uint16 {
switch {
case n < 92:
return uint16(nfkcValues[n<<6+uint32(b)])
default:
n -= 92
return uint16(nfkcSparse.lookup(n, b))
}
} | lookupValue determines the type of block n and looks up the value for b. | lookupValue | go | flynn/flynn | vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go | BSD-3-Clause |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.