[−][src]Crate encoji
encoji
Encode a byte buffer into emojis, and decode an emoji string into a byte vector.
Reimplementation of base_emoji
including both
encoding and decoding.
Example
let bytes = [0x6e, 0x6e, 0x6e, 0xcd]; let emojis = "π₯π₯π₯π"; assert_eq!(encoji::to_string(&bytes), emojis); assert_eq!(encoji::from_string(&emojis)[..], bytes);
Encoding (same as original implementation)
Citing the README:
The emojis used are in
emojis.json
. There are 843 emojis there, but the converter reads sequences of 8 bits at a time, and so only maps the value to the first 256 of them. To stay consistent with other renderings, make sure you don't change the order of your emojis.json.
Decoding
String is split into graphemes by the
unicode-segmentation
crate in accordance
with the Unicode Standard Annex #29. If the grapheme
isn't a mappable emoji it is skipped, else it is converted to a byte.
License
MIT. See included LICENSE
file.
Functions
from_string | Encode encoji string into buffer |
to_custom | Encode buffer as custom-mapped string |
to_names | Encode buffer as a string of emoji names |
to_string | Encode buffer as an encoji string |