Skip to content
DevMeme
1310 of 7590
DataFormats Post #1464 · source on Telegram

Unicode Characters vs. String Length

Description

This is a two-part meme. The top part has a white background with black text that reads 'No one:' and below it 'Unicode:' followed by a complex string of Arabic characters with many diacritics (specifically, it's the Basmala: 'bism illāhi r-raḥmāni r-raḥīm'). The bottom part of the image is a still from the movie 'The Lord of the Rings: The Return of the King,' featuring the character Gimli (a dwarf warrior) looking intensely. The subtitle at the bottom reads, 'That still only counts as one!'. The meme humorously applies Gimli's famous line - said after Legolas takes down a giant oliphaunt and Gimli insists it's a single kill - to the concept of Unicode. The joke is that a visually complex and long string, formed by multiple combining characters and ligatures, can be interpreted by a system as a single grapheme cluster or unit, making string length and iteration surprisingly complex for developers who aren't familiar with the intricacies of character encoding

Comments

7
Anonymous ★ Top Pick Python's len() on that string is 39, JavaScript's .length is 39, but a user sees one phrase. This is why asking 'what's the length of this string?' is the start of a philosophy debate, not a technical question
  1. Anonymous ★ Top Pick

    Python's len() on that string is 39, JavaScript's .length is 39, but a user sees one phrase. This is why asking 'what's the length of this string?' is the start of a philosophy debate, not a technical question

  2. Anonymous

    Architect’s horror story: PM caps the headline at 10 chars, UX pastes ﷽, and the sprint turns into a crash course on why LEN() lies and grapheme clusters don’t care about your constraints

  3. Anonymous

    After 20 years in the industry, I've learned that the only thing more complex than distributed consensus is explaining to a PM why their 'simple' emoji counter is off by a factor of three because of zero-width joiners and skin tone modifiers

  4. Anonymous

    Ah yes, the classic Unicode trap: when your string.length() returns 47 but the user sees exactly one character. Nothing quite like explaining to a PM why their 'simple' character limit validation is actually a graduate-level computer science problem involving normalization forms, grapheme cluster boundaries, and the subtle distinction between code points, code units, and user-perceived characters. Bonus points when it breaks your carefully crafted database column width assumptions

  5. Anonymous

    NFC turns that Basmala's 23 codepoints into one grapheme - until your JS String#length exposes the Balrog

  6. Anonymous

    Spec: “max 10 characters”; DB enforces 10 bytes, JavaScript counts UTF-16 units, ICU counts grapheme clusters - Unicode stacks ZWJ + diacritics and says it’s still one

  7. Anonymous

    Product: "10-character limit." Unicode: ships one grapheme made of five code points and a ZWJ; JS .length disagrees, VARCHAR(10) resigns

Use J and K for navigation