// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Unicode table generator. // Data read from the web. //go:build ignore // +build ignore package main import ( "flag" "log" "unicode" "unicode/utf8" "golang.org/x/text/internal/gen" "golang.org/x/text/internal/triegen" "golang.org/x/text/internal/ucd" "golang.org/x/text/unicode/norm" "golang.org/x/text/unicode/rangetable" ) var outputFile = flag.String("output", "tables.go", "output file for generated tables; default tables.go") var assigned, disallowedRunes *unicode.RangeTable var runeCategory = map[rune]category{} var overrides = map[category]category{ viramaModifier: viramaJoinT, greek: greekJoinT, hebrew: hebrewJoinT, } func setCategory(r rune, cat category) { if c, ok := runeCategory[r]; ok { if override, ok := overrides[c]; cat == joiningT && ok { cat = override } else { log.Fatalf("%U: multiple categories for rune (%v and %v)", r, c, cat) } } runeCategory[r] = cat } func init() { if numCategories > 1<= 0x0021 && r <= 0x007e: // Is ASCII 7 p = pValid case unicode.In(r, disallowedRunes, unicode.Cc): p = disallowed case hasCompat(r): p = idDisOrFreePVal case isLetterDigits(r): p = pValid case isIdDisAndFreePVal(r): p = idDisOrFreePVal default: p = disallowed } cat := runeCategory[r] // Don't set category for runes that are disallowed. if p == disallowed { cat = exceptions[r].cat } propTrie.Insert(r, uint64(p)|uint64(cat)) } sz, err := propTrie.Gen(w) if err != nil { log.Fatal(err) } w.Size += sz }