Kruti Dev 轉 Unicode 如何運作:短 i 符號與 reph 為何必須移位
How Kruti Dev to Unicode conversion works (and why the short-i and reph have to move)
Kruti Dev 以拉丁字元按視覺順序儲存印地語文字,轉成 Unicode 時,轉換器須先以最長鍵序列配對,再調整短 i 符號和 reph 的位置,並處理元音組合等規則。作者提供可在瀏覽器內運作、毋須上載資料的免費轉換器,並在 GitHub 以 CC BY 4.0 開放完整對照表。
If you have ever opened an old Hindi Word file and seen esjk uke instead of मेरा नाम, you have met Kruti Dev. It is a legacy Hindi font that is still common in Indian government offices, courts and typing exams. This post explains why Kruti Dev text is not "real" Hindi, and what a converter has to do to turn it into Unicode.
Kruti Dev is a font trick, not an encoding
Unicode stores Hindi as Devanagari code points: म is U+092E, े is U+0947, and so on. Any Unicode font (Mangal, Nirmala UI, Noto Sans Devanagari) can draw them.
Kruti Dev works differently. It stores plain Latin characters and relies on the font to draw them as Devanagari shapes. The letter e is drawn as म, s as the े matra, j as र, k as the ा matra. So मेरा is really the four ASCII characters esjk.
That is why the text breaks the moment the font is missing: WhatsApp, Gmail or a website just shows the raw letters.
| Unicode | Kruti Dev 010 (what is actually stored) |
|---|---|
| मेरा नाम | esjk uke |
| हिंदी भाषा | fganh Hkk"kk |
| श्री | Jh |
| प्रधानमंत्री | iz/kkuea=h |
| भारत सरकार | Hkkjr ljdkj |
Converting is therefore not a font change. You have to read the Latin characters and rebuild the Devanagari string.
Step 1: map keys, longest match first
Most characters map one to one (d → क, j → र). But several Devanagari letters take two or more keys: Hk is भ, vk is आ, vks is ओ, and Jh is श्री. A converter has to try the longest sequence first, otherwise Hk becomes "H + ा" instead of भ.
Vowels are a good example. In Kruti Dev the full vowel आ is typed as अ + the ा matra (v + k), and ओ as अ + ो (v + ks). In Unicode these must become the single letters आ and ओ, not अ followed by a matra. So after mapping, the converter normalises those pairs.
Step 2: the short-i (ि) comes first
This is the part that trips up naive converters. On a typewriter the short-i matra ि is printed before the consonant, because that is where it appears visually. Kruti Dev keeps that order: f (ि) is typed first, then the consonant.
Unicode does the opposite. It stores the consonant first and the matra after it, and the font moves the ि to the left when drawing.
- Kruti Dev
fd→ Unicode क + ि = कि - Kruti Dev
fganh→ Unicode हिंदी
So whenever the converter sees f, it has to hold it, read the following consonant (or consonant cluster, like a half letter plus a full letter), and only then emit the ि after that cluster. You can watch this reordering happen live by pasting fganh into a Kruti Dev to Unicode converter.
Step 3: the reph (र्) comes last
The reph is the small hook on top of a letter, as in कार्य. It is a half र that belongs before the consonant it sits on. Kruti Dev types it as Z, and because it is drawn on top of the letter, it is typed after the letter and its matra.
- Kruti Dev
dk;Z→ Unicode कार्य (र् moves in front of य)
Here the converter must move र् backwards, past any matra, to the start of the cluster it belongs to. Get this wrong and you produce text that looks almost right but fails search, sorting and spell-check.
Step 4: nukta, half letters and the rest
A few smaller rules finish the job:
-
Nukta:
+after a consonant adds the dot, sod+→ क़. -
Half letters: many conjuncts have their own key (
Jis श्र,=is त्र,|is द्य info|ky;→ विद्यालय). A standalone halant is typed with~. -
Digits: Kruti Dev shows
0-9as Devanagari digits on screen, but stores ASCII digits. Decide whether you want ० १ २ or 0 1 2 in the output.
A tiny sketch in JavaScript
This is a simplified illustration of the reordering idea, not a full converter:
// map: longest Kruti Dev sequences first, e.g. { "vks": "ओ", "Hk": "भ", "d": "क", "k": "ा", ... }
function krutiToUnicode(input, map, keys /* sorted longest first */) {
let out = "";
for (let i = 0; i < input.length; ) {
const k = keys.find(key => input.startsWith(key, i));
out += k ? map[k] : input[i];
i += k ? k.length : 1;
}
// short-i: "ि" + consonant cluster -> consonant cluster + "ि"
out = out.replace(/ि((?:[क-ह]़?्)*[क-ह]़?)/g, "$1ि");
// reph: cluster (+ matras) + "र्" -> "र्" + cluster (+ matras)
out = out.replace(/((?:[क-ह]़?्)*[क-ह]़?[ा-ौ]*)र्/g, "र्$1");
return out;
}
A production converter needs more care (vowel normalisation, chandrabindu, punctuation like A for ।, and many conjunct keys), but the two regular expressions show the core problem: Kruti Dev stores visual order, Unicode stores logical order.
Try it or reuse the table
If you just need to convert a file, I built a free Kruti Dev to Unicode converter that runs entirely in the browser, so nothing is uploaded: free Kruti Dev to Unicode converter.
The full key-by-key mapping table (vowels, consonants, conjuncts, matras, nukta and digits, with test samples) is open on GitHub under CC BY 4.0: krutidev-unicode-mapping.
If you spot a character that converts wrongly, open an issue there with the font version and the expected output.
This post was written by an AI agent for KrutiDev Tool and reviewed before publishing. All Kruti Dev examples were checked against a working converter.
來源:DEV Community · dev.to