github.com/go-enjin/golang-org-x-text@v0.12.1-enjin.2/internal/export/idna/trie13.0.0.go (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build go1.16
     6  // +build go1.16
     7  
     8  package idna
     9  
    10  // appendMapping appends the mapping for the respective rune. isMapped must be
    11  // true. A mapping is a categorization of a rune as defined in UTS #46.
    12  func (c info) appendMapping(b []byte, s string) []byte {
    13  	index := int(c >> indexShift)
    14  	if c&xorBit == 0 {
    15  		p := index
    16  		return append(b, mappings[mappingIndex[p]:mappingIndex[p+1]]...)
    17  	}
    18  	b = append(b, s...)
    19  	if c&inlineXOR == inlineXOR {
    20  		// TODO: support and handle two-byte inline masks
    21  		b[len(b)-1] ^= byte(index)
    22  	} else {
    23  		for p := len(b) - int(xorData[index]); p < len(b); p++ {
    24  			index++
    25  			b[p] ^= xorData[index]
    26  		}
    27  	}
    28  	return b
    29  }