charnames

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package charnames is the Unicode character name table the launcher searches: every character the Unicode Character Database names, with its aliases, generated by internal/tools/unicodegen and embedded compressed. In memory it stays in its encoded form, each name a few varint word ids into one word list, and a search walks it without allocating.

Index

Constants

View Source
const (
	HexTail      = 0
	FirstWord    = 1
	MaxNameCodes = 15
	HasAliases   = 1 << 6
	HasGap       = 1 << 7
)

The encoding's codes: a name is a sequence of word codes, each a varint word id from FirstWord on (a word is one or more words of the name, so common phrases cost one code), or HexTail for "-" and the character's own code point in hex, which ends algorithmic names such as CJK COMPATIBILITY IDEOGRAPH-F900. An entry's head byte holds its name's code count (at most MaxNameCodes), its Kind shifted by 4, and the HasAliases and HasGap flags.

View Source
const Magic = "lys-charnames/2\n"

Magic starts the encoded table.

Variables

This section is empty.

Functions

This section is empty.

Types

type Char

type Char struct {
	Rune  rune
	Kind  Kind
	Score int32
	// contains filtered or unexported fields
}

Char is one named character found.

func (Char) Glyph

func (c Char) Glyph() string

Glyph is how c shows on its own: itself, a combining mark on a dotted circle, a C0 control as its control picture, "" for the invisible rest.

type Kind

type Kind uint8

Kind is how a character shows on its own.

const (
	// KindGraphic shows as itself.
	KindGraphic Kind = iota
	// KindCombining marks the character before it.
	KindCombining
	// KindControl is invisible: a control, format or separator character.
	KindControl
)

The kinds.

type Searcher

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

Searcher finds characters by name. It reuses its memory across searches, so a search allocates nothing once warm; it belongs to one goroutine.

func (*Searcher) Search

func (s *Searcher) Search(q *launcher.FuzzyQuery, query string, limit int) []Char

Search is the limit best characters for query, best first: each of its words starts a word of the name or of an alias, and the fuzzy score of the name (or, found only by an alias, of the name and aliases, for less) ranks them. An empty query lists the first characters. "U+2192" and a character typed as itself find that character. The result is valid until the next Search.

type Table

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

Table is the decoded name table.

func Parse

func Parse(data []byte) (*Table, error)

Parse checks an encoded table end to end and indexes its words.

func Shared

func Shared() (*Table, error)

Shared is the embedded table, decompressed on first use and kept.

func (*Table) AppendName

func (t *Table) AppendName(dst []byte, c Char) []byte

AppendName appends c's name in title case ("Rightwards Arrow").

func (*Table) Len

func (t *Table) Len() int

Len is how many characters the table names.

func (*Table) NewSearcher

func (t *Table) NewSearcher() *Searcher

NewSearcher searches t.

Jump to

Keyboard shortcuts

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