Documentation ¶
Overview ¶
Package ucd provides a parser for Unicode Character Database files, the format of which is defined in https://www.unicode.org/reports/tr44/. See https://www.unicode.org/Public/UCD/latest/ucd/ for example files.
It currently does not support substitutions of missing fields.
Index ¶
- Constants
- func Parse(r io.ReadCloser, f func(p *Parser))
- type Option
- type Parser
- func (p *Parser) Bool(i int) bool
- func (p *Parser) Comment() string
- func (p *Parser) Enum(i int, enum ...string) string
- func (p *Parser) Err() error
- func (p *Parser) Float(i int) float64
- func (p *Parser) Int(i int) int
- func (p *Parser) Next() bool
- func (p *Parser) Range(i int) (first, last rune)
- func (p *Parser) Rune(i int) rune
- func (p *Parser) Runes(i int) (runes []rune)
- func (p *Parser) String(i int) string
- func (p *Parser) Strings(i int) []string
- func (p *Parser) Uint(i int) uint
Constants ¶
const ( CodePoint = iota Name GeneralCategory CanonicalCombiningClass BidiClass DecompMapping DecimalValue DigitValue NumericValue BidiMirrored Unicode1Name ISOComment SimpleUppercaseMapping SimpleLowercaseMapping SimpleTitlecaseMapping )
UnicodeData.txt fields.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(r io.ReadCloser, f func(p *Parser))
Parse calls f for each entry in the given reader of a UCD file. It will close the reader upon return. It will call log.Fatal if any error occurred.
This implements the most common usage pattern of using Parser.
Types ¶
type Option ¶
type Option func(p *Parser)
An Option is used to configure a Parser.
var ( // KeepRanges prevents the expansion of ranges. The raw ranges can be // obtained by calling Range(0) on the parser. KeepRanges Option = keepRanges )
func CommentHandler ¶
The CommentHandler option passes comments that are on a line by itself to a given handler.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
A Parser parses Unicode Character Database (UCD) files.
func (*Parser) Enum ¶
Enum interprets and returns field i as a value that must be one of the values in enum.
func (*Parser) Next ¶
Next parses the next line in the file. It returns true if a line was parsed and false if it reached the end of the file.
func (*Parser) Range ¶
Range parses and returns field i as a rune range. A range is inclusive at both ends. If the field only has one rune, first and last will be identical. It supports the legacy format for ranges used in UnicodeData.txt.