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 7 package idna 8 9 // appendMapping appends the mapping for the respective rune. isMapped must be 10 // true. A mapping is a categorization of a rune as defined in UTS #46. 11 func (c info) appendMapping(b []byte, s string) []byte { 12 index := int(c >> indexShift) 13 if c&xorBit == 0 { 14 s := mappings[index:] 15 return append(b, s[1:s[0]+1]...) 16 } 17 b = append(b, s...) 18 if c&inlineXOR == inlineXOR { 19 // TODO: support and handle two-byte inline masks 20 b[len(b)-1] ^= byte(index) 21 } else { 22 for p := len(b) - int(xorData[index]); p < len(b); p++ { 23 index++ 24 b[p] ^= xorData[index] 25 } 26 } 27 return b 28 } 29