Documentation
¶
Overview ¶
Package confusables provides utilities to detect and normalize Unicode confusable characters.
Index ¶
- type DB
- func (db *DB) GeneratedAt() time.Time
- func (db *DB) IsConfusable(a, b string) bool
- func (db *DB) Lookup(r rune) []rune
- func (db *DB) LookupASCII(r rune) (rune, bool)
- func (db *DB) Skeleton(s string) string
- func (db *DB) SourceDate() string
- func (db *DB) SourceURL() string
- func (db *DB) ToASCII(s string) string
- func (db *DB) UnicodeVersion() string
- type Mapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the confusables database. Thread-safe after initialization.
func Default ¶
func Default() *DB
Default returns the embedded database (loaded once via sync.Once).
func (*DB) GeneratedAt ¶
GeneratedAt returns the timestamp when the database was generated.
func (*DB) IsConfusable ¶
IsConfusable checks if two strings would produce the same skeleton.
func (*DB) Lookup ¶
Lookup returns all target runes for a confusable character. Returns a defensive copy of the internal slice. Returns nil if the character has no mapping.
func (*DB) LookupASCII ¶
LookupASCII returns the ASCII equivalent of a rune, if one exists. Returns (replacement, true) for single-char ASCII mappings. Returns (0, false) for characters with no mapping or multi-char/non-ASCII targets. Note: If the input rune is already ASCII (r < 0x80), it returns (0, false) to prevent remapping characters that are already valid ASCII.
func (*DB) Skeleton ¶
Skeleton returns the TR39 skeleton of the string. Maps all confusable characters through the database, regardless of target length. Result is NOT suitable for display — use only for comparison. Implementation: NFD → map → NFD
func (*DB) SourceDate ¶
SourceDate returns the date of the source data.
func (*DB) ToASCII ¶
ToASCII replaces confusable characters with their ASCII equivalents. Only replaces characters that map to a SINGLE ASCII char (0x20-0x7E). Characters with multi-char targets or non-ASCII targets are kept as-is. Already-ASCII characters (0x00-0x7F) are always returned unchanged.
func (*DB) UnicodeVersion ¶
UnicodeVersion returns the Unicode version of the database.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
confusables-gen
command
confusables-gen is a tool to generate confusables data from unicode.org.
|
confusables-gen is a tool to generate confusables data from unicode.org. |