Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
UTF8 on terminal
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
ONEEYEMAN
Advocate
Advocate


Joined: 01 Mar 2005
Posts: 2773

PostPosted: Thu Oct 20, 2011 3:10 am    Post subject: UTF8 on terminal Reply with quote

Hi, ALL,
I have a very little problem which I would like to solve.

I have been asked by one of my teacher on how to display Russian characters in JAVA. So I created a simple java program with "System.out.println()" in gedit.
I compiled the program with "javac --encoding UTF-8 HelloRussian.java" but when running it all I see is a question marks.

So I gather that I am missing the "Terminal/Console Russian font/support".

I read this "The System Console" part, but apparently it's not enough. It looks like I need something else.

Can someone tell me what am I missing?

Thank you.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 527
Location: Germany

PostPosted: Thu Oct 20, 2011 7:35 am    Post subject: Reply with quote

"System console" is not the same as "terminal". The latter can be any terminal emulator under X windows. System console is the console that one gets without X windows. So the answer shall depend on what exactly is needed. If you are working in terminal emulator under X windows, then you normally need the emulator that supports UTF-8, then you need a font for that emulator that supports UTF-8, and then you need locale setting indicating that you want to use UTF-8. The latter is normally done by adding LANG=en_US.UTF-8 to your .bashrc or whatever other init file used by your login shell.

What you have read is about setting UTF-8 in system console. In general, the idea is the same, just the steps are different.
Back to top
View user's profile Send private message
ONEEYEMAN
Advocate
Advocate


Joined: 01 Mar 2005
Posts: 2773

PostPosted: Thu Oct 20, 2011 8:20 am    Post subject: Reply with quote

Hi,
Am I correct in the assumption that I need a UTF-8 for Russian, Chinese, Hindi, Japanese and all other non-English language? I.e. UTF8 covers all other ones?

If yes, what software I need in order to see the UTF8 characters in the GNOME/X terminal window?
And I need a point to the different fonts I need to install...

Thank you.
Back to top
View user's profile Send private message
tetromino
Retired Dev
Retired Dev


Joined: 02 Dec 2003
Posts: 215

PostPosted: Fri Oct 21, 2011 6:28 am    Post subject: Reply with quote

Assuming that you are using a terminal emulator in X:
  • Make sure that unicode USE flag is enabled (it's enabled by default for desktop profiles, but not for servers). If you want to work with Chinese, Japanese, or Korean, also make sure that the cjk USE flag is enabled. Then rebuild packages to pick up the changes in USE flags ("emerge -av --update --deep --newuse world").
  • You need fonts that support the writing systems you want to display. media-fonts/dejavu works well for most alphabetic scripts; or you can use media-fonts/corefonts if you prefer microsoft fonts. For Chinese, install media-fonts/arphicfonts and media-fonts/wqy-zenhei. For Japanese, install media-fonts/ja-ipafonts and media-fonts/mikachan-font-otf. For Indian languages, you want media-fonts/lohit-fonts. For national minority languages of Russia, you want media-fonts/paratype. Etc.
  • You need a unicode locale in your shell. The easiest solution is to add something like "export LANG=en_US.UTF-8" to your ~/.bashrc (assuming you are using bash and want messages displayed in US English by default).
  • You need to make sure that the terminal emulator program itself is using a unicode locale! (This is a step that many people forget). The easiest way to do that is to make your entire desktop session use unicode from the moment you log in. There is probably some setting in your desktop environment's control panel or control center to set your locale; check that the locale you chose uses UTF-8. You can also change it manually by editing certain config files; for example, for gnome-2, you can edit ~/.dmrc so it contains something like
    Code:
    [Desktop]
    Session=gnome
    Language=en_US.UTF-8
    and for gnome-3, you can edit the file named after your username in /var/lib/AccountsService/users/
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 527
Location: Germany

PostPosted: Fri Oct 21, 2011 8:38 am    Post subject: Reply with quote

Just a note. I use x11-terms/terminal and this one has very good support for UTF-8. Eterm does not have support for UTF-8. The regular xterm should
also work, provided the locale is set correctly. Just run "locale" in your terminal. If it reports something like LANG=en_US.UTF-8 then you are set.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum