Skip to content
Snippets Groups Projects
Select Git revision
  • 833da3f33a5c727a8d7ccd034c43497c66793026
  • master default protected
  • better-queue
3 results

tables10.0.0.go

Blame
  • tables10.0.0.go 110.90 KiB
    // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
    
    // +build go1.10
    
    package bidi
    
    // UnicodeVersion is the Unicode version from which the tables in this package are derived.
    const UnicodeVersion = "10.0.0"
    
    // xorMasks contains masks to be xor-ed with brackets to get the reverse
    // version.
    var xorMasks = []int32{ // 8 elements
    	0, 1, 6, 7, 3, 15, 29, 63,
    } // Size: 56 bytes
    
    // 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.
    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 {