Surrogate & grapheme JS cited closed

lodash _.toArray splits a tag-sequence flag emoji into code points

toArray splits a tag-sequence flag emoji into code points

lodash · lodash/lodash

Symptom

_.toArray splits an emoji built from a tag sequence (a subdivision flag) into its component code points instead of returning it as one element.

Minimal repro
_.toArray for the England flag emoji (a base flag plus tag characters) returns seven pieces instead of one.
Fix

Use a Unicode-aware iterator such as Intl.Segmenter that handles tag sequences when converting a string to an array.

Upstream issue → #lodash-toarray-tag-sequence

Also in: JavaScript

← all 93 entries