Module: Fontisan::Cldr::UnicodeSetParser
- Defined in:
- lib/fontisan/cldr/unicode_set_parser.rb
Overview
Parses ICU UnicodeSet bracket notation as used in CLDR exemplarCharacters fields.
Supported syntax (sufficient for exemplar sets):
- Single chars: `a`, `à`, any BMP or supplementary codepoint
- Ranges: `a-z`, `A-Z`
- Escapes: `\uXXXX`, `\UXXXXXXXX`, `\u{XXXX...}`
- Negation: `[^...]` (inverts against 0..0x10FFFF)
Unsupported (CLDR exemplars do not use these; raise ParseError):
- Property syntax `[:script=Latin:]`
- Set operations `[a-z & [b-c]]`
- Nested sets `[a[b-c]]`
- Named sequences `{a b c}`
Output: sorted, deduplicated Array
Defined Under Namespace
Classes: ParseError
Class Method Summary collapse
-
.call(set_string) ⇒ Array<Integer>
Sorted, deduplicated codepoints.
Class Method Details
.call(set_string) ⇒ Array<Integer>
Returns sorted, deduplicated codepoints.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fontisan/cldr/unicode_set_parser.rb', line 30 def call(set_string) unless set_string.start_with?("[") && set_string.end_with?("]") raise ParseError, "input must be bracketed" end body = set_string[1..-2] negate = body.start_with?("^") body = body[1..] if negate cps = parse_body(body) cps = invert(cps) if negate cps.sort.uniq end |