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.
5 //go:generate go run gen.go gen_bits.go
7 // Package runenames provides rune names from the Unicode Character Database.
8 // For example, the name for '\u0100' is "LATIN CAPITAL LETTER A WITH MACRON".
10 // See http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
17 // Name returns the name for r.
18 func Name(r rune) string {
19 i := sort.Search(len(table0), func(j int) bool {
21 rOffset := rune(e >> shiftRuneOffset)
29 rOffset := rune(e >> shiftRuneOffset)
30 rLength := rune(e>>shiftRuneLength) & maskRuneLength
31 if r >= rOffset+rLength {
35 if (e>>shiftDirect)&maskDirect != 0 {
36 o := int(e>>shiftDataOffset) & maskDataOffset
37 n := int(e>>shiftDataLength) & maskDataLength
41 base := uint32(e>>shiftDataBase) & maskDataBase
43 j := rune(e>>shiftTable1Offset) & maskTable1Offset
45 d0 := base + uint32(table1[j-1]) // dataOffset
46 d1 := base + uint32(table1[j-0]) // dataOffset + dataLength