tr51

package module
v0.0.0-...-940d48f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 2

README

Library for processing TR51 data from Unicode, published here. Supports all versions: 1.0, 2.0, 3.0, 4.0, 5.0, and 11.0+. This repository doesn't contain any TR51 data, except for small samples for testing.

Documentation on godoc.

Extras

See demo for a demo which prints all emoji.

The emoji package contains high-level normalization and helper code.

License

Released under Apache-2.0.

Documentation

Overview

Package tr51 implements a parser for TR51 data from Unicode (https://unicode.org/Public/emoji/).

Index

Constants

View Source
const (
	// VS16 is the "Variation Selector 16" rune, commonly known as "emoji mode".
	VS16 = 0xfe0f
)

Variables

View Source
var (

	// ErrInvalidRange indicates bad TR51 data.
	ErrInvalidRange = errors.New("invalid emoji range")

	// ErrUnhandledEscape indicates that an unhandled escape was reached.
	// This library special-cases escapes as there's not many of them.
	ErrUnhandledEscape = errors.New("unhandled \\x escape code")
)

Functions

func Origins

func Origins(o string) []string

Origins converts a space-separated list of origins from the Emoji 1.0 data, to long-form text useful for types.

func ReadFunc

func ReadFunc(r io.Reader, fn func(Line) error) error

ReadFunc reads an io.Reader and passes each Line to the specified method.

func Unqualify

func Unqualify(o string) string

Unqualify removes all VS16 charaters from the input string.

Types

type Line

type Line struct {
	Single     rune     // for single rune emoji
	Low, High  rune     // for low/high pairs e.g., AAAA..BBBB
	Sequence   []rune   // for runs of emoji e.g., 1F468 200D 2764 FE0F
	Version    float32  // unicode version
	Notes      string   // trailing notes as part of comment
	Properties []string // ;-separated properties
}

Line represents all possible raw line parts of a TR51 doc.

func Parse

func Parse(line []byte) (out Line, err error)

Parse parses a single line of a TR51 doc.

func (*Line) AsRange

func (lp *Line) AsRange() (low, high rune)

AsRange returns single or ranged emoji as a range.

func (*Line) AsSequence

func (lp *Line) AsSequence() []rune

AsSequence returns single or sequenced emoji as a sequence.

func (*Line) AsString

func (lp *Line) AsString() string

AsString returns single or sequenced emoji as a string, or returns an empty stirng.

func (*Line) Each

func (lp *Line) Each(fn func([]rune))

Each calls the passed callback for every rune or sequence.

func (*Line) HasEmoji

func (lp *Line) HasEmoji() bool

HasEmoji returns whether this line has any emoji parts.

func (*Line) HasProperty

func (lp *Line) HasProperty(s string) bool

HasProperty returns whether this line has the given property.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader allows reading of TR51 data.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a new Reader for TR51 data.

func (*Reader) Read

func (r *Reader) Read() (Line, error)

Read returns the next line of TR51 data. If no line is available, returns an error.

Directories

Path Synopsis
Package main of datagen generates processed emoji data as a ESM for JavaScript.
Package main of datagen generates processed emoji data as a ESM for JavaScript.
Package main will print all emoji from the latest revision, except unqualified emoji.
Package main will print all emoji from the latest revision, except unqualified emoji.
Package emoji provides some higher-level abstractions over the emoji-data.txt and emoji-test.txt TR51 data files.
Package emoji provides some higher-level abstractions over the emoji-data.txt and emoji-test.txt TR51 data files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL