trie13.0.0.go 872 B

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