Handling Unicode Graphemes and Real-Time WPM in a Bengali-English Typing Engine
Lessons learned building a dual-language (বাংলা & English) typing benchmark in React and Next.js without Unicode splitting bugs or keystroke lag.
Abdul Malek
Full-Stack Developer (MERN & Next.js)
Why Bengali Unicode Breaks Naive String Splitting
In English, almost every visible character corresponds to a single UTF-16 code unit, so `text.split("")` works as expected. In Bengali (বাংলা), words frequently include vowel diacritics (কার, such as া, ি, ী) and conjunct consonants (যুক্তবর্ণ formed with হসন্ত `্`).
If a typing test splits a Bengali sentence with `split("")`, a base consonant and its vowel sign are separated into different array indices, breaking both the visual rendering of the target passage and the character comparison state.
Normalizing Input with NFC and Grapheme Segmentation
Different Bengali keyboard layouts (such as Avro Phonetic and Bijoy Unicode) can emit visually identical characters using slightly different sequences of Unicode code points. Applying `.normalize("NFC")` to both the target passage and the user’s input ensures canonical equivalence before comparing characters.
// Normalize both target and user input before comparison
const normalizedTarget = targetPassage.normalize('NFC');
const normalizedInput = userInput.normalize('NFC');Calculating Net WPM and Accuracy in Real Time
Standard typing benchmarks define 1 word as 5 characters so that passage difficulty does not skew WPM scores across languages. By tracking elapsed active time and separating correct keystrokes from uncorrected errors, the UI updates net WPM and accuracy smoothly while keeping component re-renders scoped to the active word.
Real-World Implementation
See how these patterns were applied in production by reading the related project case study.
Related Technical Articles
Architecting a Multi-Admin E-Commerce & CMS Platform with Next.js and MongoDB
A practical engineering breakdown of server-verified order pricing, role-based access control, and schema design for a production Next.js and MongoDB commerce platform.
Read article Cloud & Media Engineering · 5 min readImplementing Secure Signed Cloudinary Media Uploads in Next.js App Router
How to upload high-resolution project screenshots and 100 MB walkthrough videos directly from the browser to Cloudinary using server-issued SHA-1 signatures.
Read article