1 // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
5 // This code is shared between the main code generator and the test code.
13 "golang.org/x/text/internal/gen"
14 "golang.org/x/text/internal/ucd"
18 outputFile = flag.String("out", "tables.go", "output file")
21 var typeMap = map[string]elem{
30 // getWidthData calls f for every entry for which it is defined.
32 // f may be called multiple times for the same rune. The last call to f is the
33 // correct value. f is not called for all runes. The default tag type is
35 func getWidthData(f func(r rune, tag elem, alt rune)) {
36 // Set the default values for Unified Ideographs. In line with Annex 11,
37 // we encode full ranges instead of the defined runes in Unified_Ideograph.
38 for _, b := range []struct{ lo, hi rune }{
39 {0x4E00, 0x9FFF}, // the CJK Unified Ideographs block,
40 {0x3400, 0x4DBF}, // the CJK Unified Ideographs Externsion A block,
41 {0xF900, 0xFAFF}, // the CJK Compatibility Ideographs block,
42 {0x20000, 0x2FFFF}, // the Supplementary Ideographic Plane,
43 {0x30000, 0x3FFFF}, // the Tertiary Ideographic Plane,
45 for r := b.lo; r <= b.hi; r++ {
50 inverse := map[rune]rune{}
51 maps := map[string]bool{
56 // We cannot reuse package norm's decomposition, as we need an unexpanded
57 // decomposition. We make use of the opportunity to verify that the
58 // decomposition type is as expected.
59 ucd.Parse(gen.OpenUCDFile("UnicodeData.txt"), func(p *ucd.Parser) {
61 s := strings.SplitN(p.String(ucd.DecompMapping), " ", 2)
65 x, err := strconv.ParseUint(s[1], 16, 32)
67 log.Fatalf("Error parsing rune %q", s[1])
69 if inverse[r] != 0 || inverse[rune(x)] != 0 {
70 log.Fatalf("Circular dependency in mapping between %U and %U", r, x)
76 // <rune range>;<type>
77 ucd.Parse(gen.OpenUCDFile("EastAsianWidth.txt"), func(p *ucd.Parser) {
78 tag, ok := typeMap[p.String(1)]
80 log.Fatalf("Unknown width type %q", p.String(1))
84 if tag == tagFullwidth || tag == tagHalfwidth && r != wonSign {
87 log.Fatalf("Narrow or wide rune %U has no decomposition", r)