Emoji look simple: one little picture. For developers, they are one of the most common sources of subtle bugs, such as truncated messages, broken character counters, mangled database rows and cursor positions that jump. This post explains how emoji are encoded and how to handle them correctly.
Emoji are Unicode characters, sometimes several
Each basic emoji has a Unicode code point . π is U+1F600 ("grinning face"), and π is U+1F480 ("skull"). These code points live outside the Basic Multilingual Plane, which already causes trouble in languages that use UTF-16 internally.
" π " . length ; // 2 (two UTF-16 code units, a surrogate pair) [... " π " ].β¦