How to add Hindi, gujarati, kannada or any Indian language in a website

  1. Previous
  2. Next
  3. Recent

    1. Signs 'He' May be Cheating on You
    2. 7 Vows of Hindu Marriage - Know What 'Saat Vachans' Mean
    3. RuPay vs Visa vs Mastercard vs American Express- A Comparison
    4. What is RuPay? Everything You Need to Know About India's Domestic Payment System!
    5. Top 10 Online Portals to Find a High Paying Job in India
    6. Top Indians who Revolutionized the IT Sector in India
    7. 8 Initiatives by Narendra Modi that Could Change the Future of the Nation
    8. 8 Work-from-home Jobs for Housewives, Students, and Part timers
    9. Complete Company Registration Process in India - Explained
    10. Change Name in India in 5 Steps - Filing Affidavit, Newspaper Ad & Gazette Notification

This is a part of very old discussion yet most of us find problems in adding Hindi lines to a website. But after reading this blog, you won’t find it difficult to write any language in a website.

The reason for Hindi’s strange behavior

We can’t add Hindi just like English because Hindi letters needs more than 1 byte to encode. All English letters and symbols are among the first 128 characters of the Unicode character set that needs 1 byte encoding. Next 1920 characters are of languages like Chinese, Arabic, and Greek that require 2 bytes to encode. Letters and symbols of other languages including Hindi need 3 to 4 bytes to encode.

English letters can be encoded using any encoding scheme (ASCII, , UCS-2, UTF-8 etc), but Hindi and other Indian languages must be encoded in UTF-8 to become readable for web languages (php, html, js etc) since they are outside the 128 character mark and need more than 1 byte to encode.

Not only Hindi, other languages like Chinese, Japanese, Thai, French all must be encoded in UTF-8.

Add Hindi by encoding charcters in UTF-8

By default, we use a text editors like notepad or notepad++ to write codes. For adding Hindi/Kannada or any language, just change the encoding from ANSI to UTF-8 as shown in the image below. Next compile the code and run the page.

change character encoding to utf-8

Changing encoding in Notepad++

You should see the Hindi text displaying on the webpage. In the same way, you can develop an entire site in Hindi.

add hindi language to webpage

One thing to note here is that, you must specify a Hindi font name for the text. One font could be ‘Mangal’ that comes default in windows.

Here is a quick stepwise instructions on adding Hindi in websites.

  1. Write Hindi content in MS Word.
  2. Set encoding of text editor to UTF-8.
  3. Add Hindi text to the webpage just like English text. Also set the font name as ‘Mangal’.

    <p style=’font-family: Mangal’> hindi text </p>

  4. Save the webage and run.
  5. That’s all! You should see your Hindi text on the page.

This works on all browser and there is no compatibility issue. By changing the encoding and setting the right  font, we can write Hindi, Gujarati, Chinese or any other language in a website.

blog comments powered by Disqus