Unicode and UTF-8 for Hindi: Code Points, Bytes and How Devanagari Is Stored
When Hindi text breaks – boxes instead of letters, "lqcg" instead of सुबह, a form saying your name is "too long" – the cause is almost always encoding. This explainer covers the three layers you need to know as a CS/IT student or as anyone who types Hindi on computers: characters and code points (Unicode), bytes (UTF-8), and how Devanagari is stored and shown. The facts come from the Unicode Standard and IETF RFC 3629.
In short: Unicode gives every character a number (a code point). Devanagari uses the block U+0900–U+097F. UTF-8 stores each code point in 1 to 4 bytes, and every Devanagari character takes 3 bytes. Hindi is stored in phonetic order (consonant, then vowel sign), and the font rearranges it on screen.
Layer 1: code points
Unicode assigns each character a code point, written U+ followed by hexadecimal digits. Some Devanagari examples from the Unicode code chart:
| Character | Code point | Name / role |
|---|---|---|
| क | U+0915 | Consonant KA |
| न | U+0928 | Consonant NA |
| ि | U+093F | Vowel sign I (shown on the left) |
| े | U+0947 | Vowel sign E |
| ् | U+094D | Sign virama (halant) |
A code point is an abstract number. It says nothing about bytes, fonts or appearance. That separation is what lets the same text appear correctly in any Unicode font.
Layer 2: UTF-8 bytes
RFC 3629 defines UTF-8, the dominant encoding on the web. The number of bytes depends on the code point range:
| Code point range | Bytes | Bit pattern | Examples |
|---|---|---|---|
| U+0000 – U+007F | 1 | 0xxxxxxx | A–Z, 0–9 (same as ASCII) |
| U+0080 – U+07FF | 2 | 110xxxxx 10xxxxxx | Accented Latin, Greek, Arabic |
| U+0800 – U+FFFF | 3 | 1110xxxx 10xxxxxx 10xxxxxx | All Devanagari, ₹ (U+20B9) |
| U+10000 – U+10FFFF | 4 | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx | Emoji |
Worked example: नमस्ते
| Character | Code point | UTF-8 bytes |
|---|---|---|
| न | U+0928 | E0 A4 A8 |
| म | U+092E | E0 A4 AE |
| स | U+0938 | E0 A4 B8 |
| ् | U+094D | E0 A5 8D |
| त | U+0924 | E0 A4 A4 |
| े | U+0947 | E0 A5 87 |
The word looks like 4 letters on screen, but it is 6 code points and 18 bytes in UTF-8. The English word "namaste" is 7 bytes. That is why a database column or form field limited by bytes fills up about three times faster with Hindi.
JavaScript adds a third count. MDN notes that a string's length counts UTF-16 code units. Every Devanagari character is one UTF-16 unit, so "नमस्ते".length is 6, while an emoji counts as 2. A form that limits "characters" may therefore count something different from what you see.
Layer 3: how Devanagari is stored and shown
Phonetic order
The Unicode Standard says Devanagari text "generally follows phonetic order": a consonant followed by a vowel sign is stored as the consonant first, then the vowel sign. The vowel sign ि (U+093F) is drawn to the left of its consonant, yet in memory it comes after it. In कि the bytes are क then ि. Typewriter-era fonts such as Kruti Dev did the opposite: you type the ि key first because it appears first. This mismatch is one of the main things a Kruti Dev to Unicode converter has to fix.
Virama and conjuncts
The virama (्, U+094D) "kills" the inherent vowel of a consonant. The Unicode Standard defines a dead consonant as a consonant followed by a virama. स + ् + त is stored as three code points, and the font decides whether to draw a half-letter or a ligature (स्त). The visual result can be one combined shape, but the text is still separate characters, which is why the cursor and backspace sometimes move "inside" a conjunct.
Fonts do the shaping
Converting code points into the right glyph shapes is the job of the font and the text-shaping engine. A missing or broken Devanagari font gives boxes or dotted circles (◌ि). The fix is a proper Unicode font such as Mangal or Noto Sans Devanagari. The data itself does not need to change.
Unicode vs legacy fonts (Kruti Dev)
| Unicode | Kruti Dev 010 | |
|---|---|---|
| What is stored | Devanagari code points (U+09xx) | Latin letters, for example lqcg |
| What makes it look Hindi | Any Devanagari font | Only the Kruti Dev font |
| Search, sorting, spell-check | Works | Does not work as Hindi |
| Web forms, email, phones | Displays correctly | Shows English gibberish |
| OCR output | Unicode | Not applicable |
The Kruti Dev ↔ Unicode guide explains the conversion step by step. What is OCR explains why scanned Hindi needs a Devanagari OCR model.
Common encoding bugs and their causes
- "नम..." gibberish – UTF-8 bytes read as a single-byte encoding (Windows-1252 or Latin-1). Each Hindi character turns into three odd Latin characters. Fix: open or declare the file as UTF-8.
- Question marks "????" – the text was saved in an encoding that cannot represent Devanagari, and the characters were replaced permanently.
- CSV opens garbled in a spreadsheet – the program guessed the wrong encoding. Import the file and choose UTF-8 explicitly.
Exercise
- In a browser console, run
new TextEncoder().encode("नमस्ते").length(18) and"नमस्ते".length(6). - Type कि in Unicode, then use your arrow keys and backspace on it and notice the order.
- Paste Kruti Dev text into the converter and compare the code points before and after.
Convert Kruti Dev text to Unicode and back.
Open the converterFrequently asked questions
How many bytes is a Hindi character in UTF-8?
Every Devanagari code point (U+0900–U+097F) takes 3 bytes. A visible syllable such as स्ते can be several code points.
Why is ि typed after the consonant in Unicode?
Unicode stores Devanagari in phonetic order: consonant first, then the vowel sign, even though ि is drawn on the left.
Why do I see ठcharacters instead of Hindi?
UTF-8 bytes were read as a single-byte encoding. Open or import the file as UTF-8.
Sources
- The Unicode Standard 16.0 – Chapter 12: South and Central Asia-I (Devanagari)
- Unicode Consortium – Devanagari code chart (U+0900–U+097F)
- IETF RFC 3629 – UTF-8, a transformation format of ISO 10646
- MDN Web Docs – String: length (UTF-16 code units)
- MDN Web Docs – TextEncoder
Sources checked on 23 November 2026. Official notices and orders change; the latest version on the issuing body's website is final.