A simple React web application that accurately counts graphemes in text, including emojis and complex characters.
Intl.Segmenter for accurate resultsGraphemes are the smallest units of a writing system. They can be:
For example, "dinosaurs ๐ฆ ๐๐ดโ๏ธ" contains 14 graphemes: "d", "i", "n", "o", "s", "a", "u", "r", "s", " ", "๐ฆ", "๐", "๐ด", "โ๏ธ".
Intl.Segmenter with granularity: 'grapheme'โโโ backend/
โ โโโ index.ts # Hono server entry point
โโโ frontend/
โ โโโ components/
โ โ โโโ App.tsx # Main React component with all logic
โ โโโ index.html # HTML template
โ โโโ index.tsx # React entry point
โโโ README.md
| Text | Graphemes | Characters | Words |
|---|---|---|---|
| "dinosaurs ๐ฆ ๐๐ดโ๏ธ" | 14 | 20 | 2 |
| "Hello World! ๐" | 13 | 15 | 2 |
| "cafรฉ ๐ต" | 6 | 8 | 2 |
| "๐จโ๐ฉโ๐งโ๐ฆ" | 1 | 7 | 1 |
The app uses Intl.Segmenter which is supported in:
For older browsers, it falls back to character counting.
This is a Val Town project. The main entry point is backend/index.ts which serves the React application.
To run locally with Deno:
deno run --allow-net --allow-read backend/index.ts