unicode-pitfalls

Installation
SKILL.md

Unicode pitfalls

Length has three meanings

For "πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦" (family emoji):

Measure Value Use for
Bytes (UTF-8) 25 Storage limits, network buffers
Code points 7 Almost never
Grapheme clusters 1 Anything a user sees or counts

len() in Python and .length in JS give code points (JS gives UTF-16 units, so emoji count as 2). Neither matches what a user calls a character.

import regex
len(regex.findall(r'\X', s))     # grapheme clusters
Installs
1
First Seen
9 days ago
unicode-pitfalls β€” auralshin/coding-skills