<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Girish Kapale</title>
    <description>The latest articles on DEV Community by Girish Kapale (@typingpariksha).</description>
    <link>https://dev.to/typingpariksha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4282571%2Fcd2d2f4d-fb42-4cfe-b6a1-186568f43b16.png</url>
      <title>DEV Community: Girish Kapale</title>
      <link>https://dev.to/typingpariksha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/typingpariksha"/>
    <language>en</language>
    <item>
      <title>How I Built a Kruti Dev to Unicode (Mangal) Converter in Plain JavaScript</title>
      <dc:creator>Girish Kapale</dc:creator>
      <pubDate>Fri, 04 Dec 2026 10:54:12 +0000</pubDate>
      <link>https://dev.to/typingpariksha/how-i-built-a-kruti-dev-to-unicode-mangal-converter-in-plain-javascript-4j5f</link>
      <guid>https://dev.to/typingpariksha/how-i-built-a-kruti-dev-to-unicode-mangal-converter-in-plain-javascript-4j5f</guid>
      <description>&lt;p&gt;If you have ever opened an old Hindi office file and seen text like &lt;code&gt;Hkkjr ,d fo'kky ns'k gSA&lt;/code&gt;, you have met &lt;strong&gt;Kruti Dev 010&lt;/strong&gt;. It is a legacy, non-Unicode font: it draws Hindi shapes on top of plain English keys. Without the font installed, the text is gibberish.&lt;/p&gt;

&lt;p&gt;Unicode Hindi (what fonts like Mangal display) stores real Devanagari characters: &lt;code&gt;भारत एक विशाल देश है।&lt;/code&gt;. I needed a converter for my free Hindi typing test site, so I wrote a small dependency-free library that goes both ways. Here is what made it interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Simple mapping is not enough
&lt;/h2&gt;

&lt;p&gt;The first version is just a lookup table: &lt;code&gt;k&lt;/code&gt; -&amp;gt; &lt;code&gt;ा&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt; -&amp;gt; &lt;code&gt;क&lt;/code&gt;, &lt;code&gt;fg&lt;/code&gt; ... and so on. Kruti Dev uses multi-character glyphs, so the lookup has to be &lt;strong&gt;greedy&lt;/strong&gt;: always try the longest key first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greedy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;hit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;hit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. The chhoti i matra is typed in the wrong order
&lt;/h2&gt;

&lt;p&gt;In Kruti Dev you type &lt;code&gt;f&lt;/code&gt; (ि) &lt;strong&gt;before&lt;/strong&gt; the consonant, because that is where it appears visually. In Unicode, the matra comes &lt;strong&gt;after&lt;/strong&gt; the consonant (and after the whole conjunct). So &lt;code&gt;fd&lt;/code&gt; must become &lt;code&gt;कि&lt;/code&gt;, and &lt;code&gt;fLFkj&lt;/code&gt; must become &lt;code&gt;स्थिर&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The fix: mark the pre-base matra during mapping, then move it past the next full syllable (consonant + any halant + consonant chain) with a regex.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Reph (र्) goes the other way
&lt;/h2&gt;

&lt;p&gt;The reph glyph is typed &lt;strong&gt;after&lt;/strong&gt; the syllable in Kruti Dev, but in Unicode &lt;code&gt;र्&lt;/code&gt; comes &lt;strong&gt;before&lt;/strong&gt; it. &lt;code&gt;deZ&lt;/code&gt; is &lt;code&gt;कर्म&lt;/code&gt;. Same idea, reversed: find the syllable that ends before the reph marker and put &lt;code&gt;र्&lt;/code&gt; in front.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Half letters and the "aa bar"
&lt;/h2&gt;

&lt;p&gt;Kruti Dev often builds a full consonant from a half glyph plus the vertical bar &lt;code&gt;k&lt;/code&gt;. So &lt;code&gt;Hk&lt;/code&gt; is &lt;code&gt;भ&lt;/code&gt; (half bha + bar), but &lt;code&gt;Hkk&lt;/code&gt; is &lt;code&gt;भा&lt;/code&gt;. The converter has to know which glyphs are half forms and join them correctly, or you get a stray &lt;code&gt;ा&lt;/code&gt; everywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Going back: Unicode -&amp;gt; Kruti Dev
&lt;/h2&gt;

&lt;p&gt;The reverse direction needs the same rules undone: move ि before the syllable, move र् after it, and split full consonants into half + bar where the font expects it. Digits are another trap: some people want Devanagari digits, some want 0-9, so it is an option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nc"&gt;KrutiDev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUnicode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hkkjr ,d fo'kky ns'k gSA"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// "भारत एक विशाल देश है।"&lt;/span&gt;
&lt;span class="nc"&gt;KrutiDev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromUnicode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"भारत एक विशाल देश है।"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// "Hkkjr ,d fo'kky ns'k gSA"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Try it or use the code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The library is MIT licensed on GitHub: &lt;a href="https://github.com/girishkapale/kruti-dev-unicode-converter" rel="noopener noreferrer"&gt;kruti-dev-unicode-converter&lt;/a&gt;. It also lets you plug in other legacy fonts (DevLys, Shree Lipi) with &lt;code&gt;registerFont()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If you just need to convert text, the free online &lt;a href="https://typingpariksha.in/mangal-to-kruti-dev/" rel="noopener noreferrer"&gt;Mangal to Kruti Dev converter&lt;/a&gt; runs the same code in your browser. Nothing is uploaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I built it for &lt;a href="https://typingpariksha.in/" rel="noopener noreferrer"&gt;TypingPariksha.in&lt;/a&gt;, a free Hindi typing test for SSC, CPCT and RRB exam students, where many practice passages still come in Kruti Dev.&lt;/p&gt;

&lt;p&gt;If you have handled other legacy Indic fonts, I would love to hear which edge cases bit you.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>unicode</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
