| 1 |
// Copyright 2015 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. |
| 4 |
|
| 5 |
//go:build ignore |
| 6 |
|
| 7 |
package main |
| 8 |
|
| 9 |
import ( |
| 10 |
"unicode" |
| 11 |
|
| 12 |
"golang.org/x/text/internal/gen" |
| 13 |
"golang.org/x/text/internal/ucd" |
| 14 |
"golang.org/x/text/unicode/rangetable" |
| 15 |
) |
| 16 |
|
| 17 |
// These tables are hand-extracted from: |
| 18 |
// https://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt |
| 19 |
func visitDefaults(fn func(r rune, c Class)) { |
| 20 |
// first write default values for ranges listed above. |
| 21 |
visitRunes(fn, AL, []rune{ |
| 22 |
0x0600, 0x07BF, // Arabic |
| 23 |
0x08A0, 0x08FF, // Arabic Extended-A |
| 24 |
0xFB50, 0xFDCF, // Arabic Presentation Forms |
| 25 |
0xFDF0, 0xFDFF, |
| 26 |
0xFE70, 0xFEFF, |
| 27 |
0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols |
| 28 |
}) |
| 29 |
visitRunes(fn, R, []rune{ |
| 30 |
0x0590, 0x05FF, // Hebrew |
| 31 |
0x07C0, 0x089F, // Nko et al. |
| 32 |
0xFB1D, 0xFB4F, |
| 33 |
0x00010800, 0x00010FFF, // Cypriot Syllabary et. al. |
| 34 |
0x0001E800, 0x0001EDFF, |
| 35 |
0x0001EF00, 0x0001EFFF, |
| 36 |
}) |
| 37 |
visitRunes(fn, ET, []rune{ // European Terminator |
| 38 |
0x20A0, 0x20Cf, // Currency symbols |
| 39 |
}) |
| 40 |
rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) { |
| 41 |
fn(r, BN) // Boundary Neutral |
| 42 |
}) |
| 43 |
ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) { |
| 44 |
if p.String(1) == "Default_Ignorable_Code_Point" { |
| 45 |
fn(p.Rune(0), BN) // Boundary Neutral |
| 46 |
} |
| 47 |
}) |
| 48 |
} |
| 49 |
|
| 50 |
func visitRunes(fn func(r rune, c Class), c Class, runes []rune) { |
| 51 |
for i := 0; i < len(runes); i += 2 { |
| 52 |
lo, hi := runes[i], runes[i+1] |
| 53 |
for j := lo; j <= hi; j++ { |
| 54 |
fn(j, c) |
| 55 |
} |
| 56 |
} |
| 57 |
} |