Class: EmojiChar

Defined in: src/emoji_char.coffee

Overview

EmojiChar represents a single Emoji character and its associated metadata.

Properties

It also contains a few helper functions to deal with this data type.

Class Method Summary

Instance Method Summary

Class Method Details

. (String) _unified_to_char(uid) Private

Convert a unified codepoint ID to the UCS-2 string representation.

Parameters:

  • uid ( String ) the unified codepoint ID for an emoji

Returns:

  • ( String ) — UCS-2 string representation of the emoji glyph

Constructor Details

# (EmojiChar) constructor(blob)

Parameters:

  • blob ( Object ) the JSON blob entry from emoji-data

Returns:

Instance Method Details

# (Boolean) is_doublebyte()

Is the EmojiChar represented by a doublebyte codepoint in Unicode?

Returns:

  • Boolean

# (Boolean) has_variants()

Does the EmojiChar have an alternate Unicode variant encoding?

Returns:

  • ( Boolean ) — true when the EmojiChar has at least one variant encoding

# (String, null) variant()

Returns the most likely variant-encoding codepoint ID for an EmojiChar.

For now we only know of one possible variant encoding for certain characters, but there could be others in the future.

This is typically used to force Emoji rendering for characters that could be represented in standard font glyphs on certain operating systems.

The resulting encoded string will be two codepoints, or three codepoints for doublebyte Emoji characters.

Returns:

  • ( String, null ) — The most likely variant-encoding codepoint ID. If there is no variant-encoding for a character, returns null.

# (String) render({variant_encoding} = { variant_encoding: true })

Renders a UCS-2 string representation of the glyph for writing to screen.

If you want to specify whether or not to use variant encoding, pass an options hash such as:

foo.char({variant_encoding: true})

By default this will use the variant encoding if it exists.

variant encoding.

Parameters:

  • options ( Object ) the encoding options

Options Hash: (options):

  • variant_encoding ( Boolean ) true if you want to render with

Returns:

  • ( String ) — the emoji character rendered to a UCS-2 string

# (Array<String>) chars()

Returns a list of all possible UTF-8 string renderings of an EmojiChar.

E.g., normal, with variant selectors, etc. This is useful if you want to have all possible values to match against when searching for the emoji in a string representation.

Returns:

  • ( Array<String> ) — all possible UCS-2 string renderings

# (String) toString()

Returns:

  • String

See also:

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: