Class: EmojiChar
| Defined in: | src/emoji_char.coffee |
Overview
EmojiChar represents a single Emoji character and its associated metadata.
Properties
name- The standardized name used in the Unicode specification to represent this emoji character.unified- The primary unified codepoint ID for the emoji.variations- A list of all variant codepoints that may also represent this emoji.short_name- The canonical "short name" or keyword used in many systems to refer to this emoji. Often surrounded by:colons:in systems like GitHub & Campfire.short_names- A full list of possible keywords for the emoji.text- An alternate textual representation of the emoji, for example a smiley face emoji may be represented with an ASCII alternative. Most emoji do not have a text alternative. This is typically used when building an automatic translation from typed emoticons.
It also contains a few helper functions to deal with this data type.
Class Method Summary
- . (String) _unified_to_char(uid) Private Convert a unified codepoint ID to the UCS-2 string representation.
Instance Method Summary
-
#
(Boolean)
is_doublebyte()
Is the
EmojiCharrepresented by a doublebyte codepoint in Unicode? -
#
(Boolean)
has_variants()
Does the
EmojiCharhave an alternate Unicode variant encoding? -
#
(String, null)
variant()
Returns the most likely variant-encoding codepoint ID for an
EmojiChar. - # (String) render({variant_encoding} = { variant_encoding: true }) Renders a UCS-2 string representation of the glyph for writing to screen.
-
#
(Array<String>)
chars()
Returns a list of all possible UTF-8 string renderings of an
EmojiChar. - # (String) toString()
Class Method Details
.
(String)
_unified_to_char(uid)
Private
Convert a unified codepoint ID to the UCS-2 string representation.
Constructor Details
#
(EmojiChar)
constructor(blob)
Instance Method Details
#
(Boolean)
is_doublebyte()
Is the EmojiChar represented by a doublebyte codepoint in Unicode?
#
(Boolean)
has_variants()
Does the EmojiChar have an alternate Unicode 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.
#
(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.
#
(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.
#
(String)
toString()