Is the context for ambiguous East Asian Width code points CJK?
Resolved locale for grapheme segmentation.
Break a string into multiple parts, such that each part has maximum cell length of width, unless a particular grapheme cluster is longer than width. Therefore, width should probably be 4 or higher to get the expected results.
String to segment
Maximum number of display cells for chunks
Yield each segment of the input string as a separate substring.
How many display cells does the given string take up? Accounts for EastAsianWidth, Emoji, combining characters, regional indicators (flags), backspaces
String to count
Compute the widths of strings in display terminal "cells" of horizontal space. Intuitionally, a plain ASCII character takes up one cell. Certain grapheme clusters may take up -1 (e.g. backspace), 0 (e.g. escape sequences), 1, or 2 (e.g. emoji) cells.
ANSI escape sequences are stripped by default. This can be disabled by setting the includeANSI option. Escape sequences that are paired with a start sequence and a stop sequence will be processed much more gracefully than individual sequences (e.g. cursor movements) or overlapping pairs.