How Charli Works
A deep look into our deterministic in-browser text engine: how Unicode characters, surrogate pairs, grapheme clusters, and formatting traps are parsed and sanitized without server round-trips.
1. Why String Length Is Deceptive
In JavaScript and many other programming languages, string.length does not measure the number of visible characters or Unicode code points. It counts 16-bit code units in UTF-16 representation. This leads to subtle, expensive bugs in production:
Code Points
The unique integer assigned by the Unicode Standard (e.g. U+1F600). JavaScript represents characters beyond U+FFFF using two 16-bit surrogate units. Charli decodes true scalar values correctly.
Grapheme Clusters
What human eyes perceive as a single distinct glyph. For example, ๐จโ๐ฉโ๐งโ๐ฆ appears as one emoji, but consists of 7 code points joined by Zero-Width Joiners. Charli uses Intl.Segmenter for exact segmentation.
Byte Allocations
In UTF-8, characters take between 1 and 4 bytes. In UTF-16, 2 or 4 bytes. In UTF-32, 4 bytes each. Charli computes byte layouts on the fly using native TextEncoder.
2. Invisible Character & Format Trap Detection
Copy-pasting from rich documents (Slack, Word, PDFs, Google Docs) introduces invisible formatting characters into strings. These break database lookups, split URLs, and trigger syntax errors in JSON parsers.
Security Threat: Trojan Source (CVE-2021-42574)
Charli checks for Bidirectional (Bidi) override characters like Left-to-Right Embedding (U+202A) and Right-to-Left Override (U+202E). Attackers use these to render code visually harmless while compiler order executes malicious payloads.
3. Safe Text Normalization with Instant Diff
Cleaning text should never be a destructive black box. Charli follows a transparent, four-phase transformation model:
Step 1
Choose Filters
Select whitespace normalization, line endings, Unicode forms, or zero-width removal.Step 2
Generate Preview
Charli runs the pipeline in memory and creates a character-level diff.Step 3
Inspect Differences
Review deletions, additions, and replacements side-by-side.Step 4
Confirm or Undo
Apply the change when satisfied, or hit Undo anytime.4. 100% In-Browser Privacy Architecture
Charli has no backend database, no remote text processing microservices, and no analytics tracking what you type. Every calculation runs client-side in your browser JavaScript thread.
Open your browser Developer Tools (F12) โ Network tab while using Charli: you will see zero outbound requests transmitting your text. Your proprietary copy, API tokens, and confidential drafts remain entirely on your device.
