UnicodeData.txt fields.
const ( CodePoint = iota Name GeneralCategory CanonicalCombiningClass BidiClass DecompMapping DecimalValue DigitValue NumericValue BidiMirrored Unicode1Name ISOComment SimpleUppercaseMapping SimpleLowercaseMapping SimpleTitlecaseMapping )
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.
An Option is used to configure a Parser.
type Option func(p *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(f func(s string)) Option
The CommentHandler option passes comments that are on a line by itself to a given handler.
func Part(f func(p *Parser)) Option
The Part option register a handler for lines starting with a '@'. The text after a '@' is available as the first field. Comments are handled as usual.
A Parser parses Unicode Character Database (UCD) files.
type Parser struct {
// contains filtered or unexported fields
}
func New(r io.Reader, o ...Option) *Parser
New returns a Parser for the given Reader.
func (p *Parser) Bool(i int) bool
Bool parses and returns field i as a boolean value.
func (p *Parser) Comment() string
Comment returns the comments for the current line.
func (p *Parser) Enum(i int, enum ...string) string
Enum interprets and returns field i as a value that must be one of the values in enum.
func (p *Parser) Err() error
Err returns a non-nil error if any error occurred during parsing.
func (p *Parser) Float(i int) float64
Float parses and returns field i as a decimal value.
func (p *Parser) Int(i int) int
Int parses and returns field i as an integer value.
func (p *Parser) Next() bool
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 (p *Parser) Range(i int) (first, last rune)
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.
func (p *Parser) Rune(i int) rune
Rune parses and returns field i as a rune.
func (p *Parser) Runes(i int) (runes []rune)
Runes interprets and returns field i as a sequence of runes.
func (p *Parser) String(i int) string
String parses and returns field i as a string value.
func (p *Parser) Strings(i int) []string
Strings parses and returns field i as a space-separated list of strings.
func (p *Parser) Uint(i int) uint
Uint parses and returns field i as an unsigned integer value.