displaying hindi in linux command prompt (terminal)
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using setlocale you're changing locale settings. Instead you can first download/install any hindi fonts and then use the same in terminal.
Or you can simply download (see here) and copy/paste the desired font in fonts folder i.e. /usr/share/.../truetype/.
But what's need of using hindi font in terminal? Do you want to use hindi in a terminal while typing commands? Or just want to set titles and menus of terminal in hindi?
Did you check whether character encoding for hindi is available in your terminal/desktop environment (Open a terminal > Open Terminal tab > Set Character Encoding > Add or Remove)?
Also what type of font's you've installed - .ttf/.otf or Postscript...?
First, we need to know if you are accessing the linux machine from another computer (putty? telnet?) or just the terminal on the linux machine itself. Because you seem to be posting from a win 7? if I am not wrong.
I am using Window 7 machine where I had vmware session installed with Red hat enterprise 4 edition.
I am accessing the linux terminal from this linux session itself...
I am posting my query in this forum from window 7 main machine.
Thanks & Regards
Vikas
Last edited by vikasmailsu; 02-06-2013 at 04:53 AM.
Check the child directories if there are any hindi fonts? From my experience is that you should set the charset of your terminal to UTF8.
Are you seeing hindi from other programs? eg firefox, text editor?
I can see the folder as follows:-
/usr/share/fonts/hi
it contain the file named fonts.cache-1 and lohit_hi.ttf
If I am not wrong , these are hindi font file too.
you can see in the terminal:-Edit->current profile->
Uncheck the system terminal font, then font button get enabled and then when you click on the font button, you can see the list of hindi as well as other font too.
As you said
"From my experience is that you should set the charset of your terminal to UTF8"
What do you mean by this?
No I am not seeing hindi from other programs? eg firefox, text editor too. I checked with text editor, and I am not able to display hindi file in text editor. But if I open the same file using cat comand , I can see the contents in the terminal
But when I use my application , that display hindi messages ; it display ??? for each hindi chracter.
If I used setlocale with hindi in my c++ programe, then if I ran the application. I can see hindi messages in the terminal too.
I would like to display Hindi messages without using setlocale function, because setlocale just change the locale setting.
Please help me .
Thanks & Regards
Vikas
Last edited by vikasmailsu; 02-06-2013 at 05:47 AM.
If I didn't get you wrong ANDDD you have your font setup correctly. Go edit your .bashrc file. Usually at ~/home/.bashrc:
make sure the following line is there or changed to:
Code:
export LANG=hi_IN.UTF-8
reboooooot and I believe you should start seeing hindi in your terminal.
Ted
@vikasmailsu:
I had asked you about type (format) of hindi fonts i.e. lohit_hi.ttf in this post.
However, in a terminal, if you will check in list of available fonts (Open a terminal > Open Edit > Select Current profile > click on Font option), you will see only Monospace type of fonts. You will not even see English or other languages fonts, which are not monospace type.
Terminals use and recognize monospace fonts only or fonts originally hinted as monospace. See here for more about monospace type font.
So, problem is not with locale or character encoding of terminal, but with type of font. lohit_hi.ttf is not a monospace font, and thus your terminal cannot recognize it, whatsoever you try.
A workaround would be to download and install a monospace type of hindi font. Apparently it will be a tough task to find a monospace type of font that is developed and hinted in devanagari script i.e. in hindi. But you should try to search it.
Note: There will a limitation! A terminal is not that smart, so it can recognize two different fonts at same time. So using hindi monospace type font in a terminal might garbled all other characters which are not in hindi.
Hope this will help!
----- ADDITIONAL INFO --------
I found a solution to convert lohin_hi.ttf font into monospace font. Try Fontforge.
And then install the new monospace type font in /usr/share/fonts (or whatever location is) and try to check it in fonts list in a terminal again.
Last edited by shivaa; 02-07-2013 at 11:42 PM.
Reason: Info. added
Thanks for responding me.
I am able to see hindi messages displayed on my terminal by using setlocale.
I would like to tell you my problem again:-
I had written a c++ program, by using that application I want to display Hindi messages on Linux terminal. When I use the function
setlocale(LC_ALL, "hi_IN.utf8")
In the main function at the very beginning of my programe.When I complie and run the appication on terminal, I am able to see the hindi messages displayed on terminal.
But as meniotned by Mr Shiva, it will change the locale settings . I would like to give the user the flexibility to change the locale according to their need, i.e application(program) won't force to change the locale, its control by user only.
If I am able to see HIndi messages on command terminal by setting setlocale(LC_ALL, "hi_IN.utf8"), then it mean font provided by Linux support hindi message display in the terminal.
Am I right or not?
If yes then by adding the
line as follows:-
export LANG=hi_IN.UTF-8
in the files bashrc and bash_profile, I am able to change my whole linux session in to Hindi.
But the time I try to run my application from terminal, I am not able to see Hindi messages instead see ?? for each character.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.