Public
Like
3
graphemeCounter
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data โ all from the browser, and deployed in milliseconds.
index.ts
https://dpip--a09f5a68555111f0baeaf69ea79377d9.web.val.run
A simple React web application that accurately counts graphemes in text, including emojis and complex characters.
- Real-time grapheme counting using
Intl.Segmenterfor accurate results - Multiple text statistics: graphemes, characters, and words
- Example texts to demonstrate complex grapheme counting
- Modern UI with TailwindCSS styling
- Responsive design that works on all devices
Graphemes are the smallest units of a writing system. They can be:
- Single characters (like "a", "b", "c")
- Emojis (like "๐ฆ", "๐")
- Combining characters (like "รฉ" which can be "e" + "ฬ")
- Complex sequences (like "๐จโ๐ฉโ๐งโ๐ฆ" which is a family emoji)
For example, "dinosaurs ๐ฆ ๐๐ดโ๏ธ" contains 14 graphemes: "d", "i", "n", "o", "s", "a", "u", "r", "s", " ", "๐ฆ", "๐", "๐ด", "โ๏ธ".
- Frontend: React 18.2.0 with TypeScript
- Backend: Hono server for serving the app
- Styling: TailwindCSS
- Grapheme Counting: Uses
Intl.Segmenterwithgranularity: 'grapheme' - Platform: Built for Val Town
โโโ 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
- Enter text in the textarea
- View real-time statistics:
- Graphemes: The number of visual units
- Characters: The total character count
- Words: The number of words
- Try the example texts to see complex grapheme counting in action
| 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:
- Chrome 87+
- Firefox 102+
- Safari 15+
- Edge 87+
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