emoji

package module
v0.0.0-...-39776ee Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 5 Imported by: 1

README

emoji

A basic wrapper around the Unicode.org emoji data files.

Import

import "libdb.so/go-emoji"

Documentation

The only function that matters:

// IsEmoji returns true if the specified rune has the (single-character)
// Emoji property in the latest Emoji version, false otherwise
func IsEmoji(r rune) bool

Go Reference: pkg.go.dev/libdb.so/go-emoji

Documentation

Index

Constants

View Source
const ZWJ = '\u200d'

ZWJ is the Unicode zero-width join character

Variables

View Source
var AllVersions = []Version{V1, V2, V3, V4, V5, V11, V12}

AllVersions lists all emoji versions in order.

Functions

func DisplayWidth

func DisplayWidth(str string) int

DisplayWidth attempts to guess at the display width of a string containing emoji, taking into account variation selectors (0xFE00-0xFE0F), zero-width joins (0x200D), combining diacritical marks (0x20d0-0x20ff), flags, and skin tone modifiers.

func IsEmoji

func IsEmoji(r rune) bool

IsEmoji returns true if the specified rune has the (single-character) Emoji property in the latest Emoji version, false otherwise.

Types

type Version

type Version int

Version represents an Emoji major release, e.g. V5 for Emoji version 5.0. Note that starting at Emoji version 11.0, the Emoji version is synchronized to the corresponding Unicode version, so there are no versions 6-10.

const (
	V1 Version = 1
	V2 Version = 2
	V3 Version = 3
	V4 Version = 4
	V5 Version = 5
	// Starting at V11, Emoji version = Unicode version
	V11 Version = 11
	V12 Version = 12

	Latest = V12
)

func (Version) FileBytes

func (v Version) FileBytes(t data.FileType) []byte

FileBytes returns the byte data of the Unicode.org source file of the specified type for this version, e.g. V12.FileBytes(Sequences) returns the contents of the file http://unicode.org/Public/emoji/12.0/emoji-sequences.txt

func (Version) HasFile

func (v Version) HasFile(t data.FileType) bool

HasFile returns true if this version has a file of the specified type, false otherwise. E.g., ZWJ (zero width joiner) sequences were introduced only in Emoji version 2.0, test files in version 4.0, and variation sequences in version 5.0.

func (Version) MergedRangeTable

func (v Version) MergedRangeTable() *unicode.RangeTable

MergedRangeTable returns the Unicode range table for all characters with all properties in this Emoji version. The list of properties can be found in data.AllProperties. Note that the range table reflects the ranges as defined in the source files from Unicode.org; ranges are guaranteed not to overlap, as per the RangeTable docs, but adjacent ranges are not coalesced.

func (Version) RangeTable

func (v Version) RangeTable(property data.Property) *unicode.RangeTable

RangeTable returns the Unicode range table for characters with the specified property in this Emoji version. Note that the range table reflects the ranges as defined in the source files from Unicode.org; ranges are guaranteed not to overlap, as per the RangeTable docs, but adjacent ranges are not coalesced.

func (Version) Sequences

func (v Version) Sequences(seqType data.SeqType) []string

Sequences returns the Unicode emoji sequences of the specified type in this Emoji version.

func (Version) String

func (v Version) String() string

String returns this version as a string, e.g. V4.String() -> "Emoji 4.0"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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