{
  "id": 2834524,
  "title": "Styled Unicode Breaks Character Counters",
  "url": "https://urgent.news/2026/08/23/styled-unicode-breaks-character-counters",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-23T17:36:52.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/3ugen/styled-unicode-breaks-character-counters-fg1"
  },
  "original_language": "en",
  "account": "Styled Unicode breaks character counters by changing the number of code points, UTF-16 units, and UTF-8 bytes. A 76-character bio with one style has the same code points as a plain text, but different UTF-16 and UTF-8 counts. A styled bio can be four times longer in storage but the counter should report code points, not bytes. When a destination only publishes a character limit, the UI should show both bytes and character counts. JavaScript strings truncate at UTF-16 boundaries, which can cause issues with styled Unicode characters. The solution is to truncate by code points or grapheme clusters instead of UTF-16 indices.",
  "summary": "A 76-character bio, styled once, no longer has one useful length. const s = \" 𝐚𝐞𝐬𝐭𝐡𝐞𝐭𝐢𝐜 \" ; [... s ]. length // 9 code points (and 9 graphemes here) s . length // 18 UTF-16 units — what String.length counts new TextEncoder (). encode ( s ). length // 36 UTF-8 bytes — what storage counts Three defensible answers, factor of four on one word. I found this while auditing a counter beside…",
  "key_points": [
    "Styled Unicode alters code points, UTF-16 units, and UTF-8 bytes",
    "Bio with one style has same code points but different UTF-16 and UTF-8 counts",
    "UI should show both bytes and character counts to avoid truncation issues"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}