2 releases
Uses old Rust 2015
0.1.1 | Sep 6, 2020 |
---|---|
0.1.0 | Jul 5, 2017 |
#9 in #byte-vector
13KB
144 lines
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.
Dependencies
~0.6–1MB
~15K SLoC