1
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
3
// Copyright 2016 The Go Authors. All rights reserved.
4
// Use of this source code is governed by a BSD-style
5
// license that can be found in the LICENSE file.
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)
15
return append(b, s[1:s[0]+1]...)
18
if c&inlineXOR == inlineXOR {
19
// TODO: support and handle two-byte inline masks
20
b[len(b)-1] ^= byte(index)
22
for p := len(b) - int(xorData[index]); p < len(b); p++ {
24
b[p] ^= xorData[index]
30
// Sparse block handling code.
32
type valueRange struct {
33
value uint16 // header: value:stride
34
lo, hi byte // header: lo:n
37
type sparseBlocks struct {
42
var idnaSparse = sparseBlocks{
43
values: idnaSparseValues[:],
44
offset: idnaSparseOffset[:],
47
// Don't use newIdnaTrie to avoid unconditional linking in of the table.
50
// lookup determines the type of block n and looks up the value for b.
51
// For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
52
// is a list of ranges with an accompanying value. Given a matching range r,
53
// the value for b is by r.value + (b - r.lo) * stride.
54
func (t *sparseBlocks) lookup(n uint32, b byte) uint16 {
56
header := t.values[offset]
58
hi := lo + uint16(header.lo)
62
if r.lo <= b && b <= r.hi {
63
return r.value + uint16(b-r.lo)*header.value