LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-13-2013, 09:33 AM   #1
narke
Member
 
Registered: Apr 2010
Posts: 197

Rep: Reputation: 5
vim can't display Chinese but gvim can


Hi,

I usually like use vim to edit source code, even in my X (fluxbox). One problem is, if in gvim I can see Chinese characters (as comments in some of my source code), but in vim (open in konsole terminal program), the same Chinese characters only displayed as unrecognized strange string.

In both gvim and Konsole, I configured to use the same font, Bitstream Versa Sans Mono. I don't understand, with the same font setting, why gvim can display Chinese but konsole+vim can not.

Where should I to check the error?

Thanks in advance.

-
woody
 
Old 07-13-2013, 02:20 PM   #2
jostber
Member
 
Registered: Jul 2001
Location: Skien, Norway
Distribution: Slackware Current 64-bit
Posts: 543

Rep: Reputation: 178Reputation: 178
Try to set another font?

http://superuser.com/questions/14195...racters-in-vim
 
Old 07-13-2013, 06:46 PM   #3
Kallaste
Member
 
Registered: Nov 2011
Distribution: Slackware
Posts: 363

Rep: Reputation: 85
I've heard of a lot of problems with Konsole and unicode characters. I could be wrong, but I'm not sure that Konsole has full unicode support. If you don't know otherwise, you might want to try another terminal that we know does have it, such as rxvt-unicode.
 
Old 07-13-2013, 09:23 PM   #4
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
I don't think there is something wrong with konsole. The OP may want to post an example file to demonstrate the problem if he really can't get rid of multi-byte characters from his source code.
Attached Thumbnails
Click image for larger version

Name:	konsole.png
Views:	60
Size:	15.2 KB
ID:	12947  
 
Old 07-13-2013, 09:25 PM   #5
narke
Member
 
Registered: Apr 2010
Posts: 197

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by BloomingNutria View Post
I've heard of a lot of problems with Konsole and unicode characters. I could be wrong, but I'm not sure that Konsole has full unicode support. If you don't know otherwise, you might want to try another terminal that we know does have it, such as rxvt-unicode.
Hi, Blooming. I just tried rxvt-unicode, it works! A Vim run in it can display Chinese!

Another thing, then how do I change the (English) font used by rxvt-unicode? I prefer Bitstream Versa Sans Mono.
 
Old 07-13-2013, 10:00 PM   #6
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by narke View Post
Another thing, then how do I change the (English) font used by rxvt-unicode? I prefer Bitstream Versa Sans Mono.
That's the font I use too. I have this in ~/.Xdefaults:
Code:
URxvt*font: xft:Bitstream\ Vera\ Sans\ Mono:style=roman:pixelsize=13:antialias=true:hinting=true
You will probably have to run
Code:
$ xrdb -merge
and restart urxvt to see the new font (or restart X).
 
Old 07-13-2013, 10:58 PM   #7
Kallaste
Member
 
Registered: Nov 2011
Distribution: Slackware
Posts: 363

Rep: Reputation: 85
Quote:
Originally Posted by guanx View Post
I don't think there is something wrong with konsole. The OP may want to post an example file to demonstrate the problem if he really can't get rid of multi-byte characters from his source code.
From what I see on Google, Unicode font rendering is a common problem in Konsole. I think it is supposed to work, but isn't quite ironed out yet. Here is a bug report:

http://kde.6490.n7.nabble.com/Bug-74190-Console-Unicode-support-not-100-there-td1251526.html


Quote:
Hi, Blooming. I just tried rxvt-unicode, it works! A Vim run in it can display Chinese!

Another thing, then how do I change the (English) font used by rxvt-unicode? I prefer Bitstream Versa Sans Mono.
Good news. I'm glad that was the only problem. You can read this to learn more about how to configure your ~/.Xresources file to change fonts, colors, and other settings:

https://wiki.archlinux.org/index.php/Rxvt-unicode
 
Old 07-13-2013, 11:44 PM   #8
narke
Member
 
Registered: Apr 2010
Posts: 197

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by guanx View Post
I don't think there is something wrong with konsole. The OP may want to post an example file to demonstrate the problem if he really can't get rid of multi-byte characters from his source code.
Guanx, interesting in see your screenshot. It seems your vim can display Chinese. I'd already set my localte to GBK, but don't know why I can't see the Chinese welcome screen of vim -- I just get English.

Below are some screenshots related to the topic. Do you have a clue about the problem? Thanks.
Attached Thumbnails
Click image for larger version

Name:	in-gvim.png
Views:	29
Size:	27.2 KB
ID:	12949   Click image for larger version

Name:	in-vim.png
Views:	37
Size:	35.3 KB
ID:	12950   Click image for larger version

Name:	vim-open-without-a-file.png
Views:	31
Size:	52.3 KB
ID:	12951  
 
Old 07-13-2013, 11:51 PM   #9
narke
Member
 
Registered: Apr 2010
Posts: 197

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by T3slider View Post
That's the font I use too. I have this in ~/.Xdefaults:
Code:
URxvt*font: xft:Bitstream\ Vera\ Sans\ Mono:style=roman:pixelsize=13:antialias=true:hinting=true
You will probably have to run
Code:
$ xrdb -merge
and restart urxvt to see the new font (or restart X).
I did the same thing, but the fonts get rendered very urgly. It looks too small, and have too much space between characters. You can check the attached screen shot. Don't know where the problem come from.
Attached Thumbnails
Click image for larger version

Name:	urxvt-bitstream-13.png
Views:	31
Size:	14.2 KB
ID:	12952  
 
Old 07-14-2013, 12:00 AM   #10
narke
Member
 
Registered: Apr 2010
Posts: 197

Original Poster
Rep: Reputation: 5
Another very strange thing is: the urxvt can display Chinese only when it is started from Konsole! If I start it directly (from fluxbox 'run' command or from fluxbox menu), it cannot display Chinese. What's wrong? Thanks.
 
Old 07-14-2013, 01:41 AM   #11
Kallaste
Member
 
Registered: Nov 2011
Distribution: Slackware
Posts: 363

Rep: Reputation: 85
Did you ever edit your /etc/profile.d/lang.sh file before this? In order to support Unicode text, I believe you need to edit that file and change the line that says

Code:
# en_US is the Slackware default locale:
export LANG=en_US
to

Code:
# en_US is the Slackware default locale:
export LANG=nl_NL.UTF-8
Also, I do not use Konsole, but there should be a setting in the menu somewhere that let's you set it to use UTF-8 directly. Try Settings -> Encoding -> Unicode (utf8).
 
Old 07-14-2013, 05:16 AM   #12
narke
Member
 
Registered: Apr 2010
Posts: 197

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by BloomingNutria View Post
Did you ever edit your /etc/profile.d/lang.sh file before this? In order to support Unicode text, I believe you need to edit that file and change the line that says

Code:
# en_US is the Slackware default locale:
export LANG=en_US
to

Code:
# en_US is the Slackware default locale:
export LANG=nl_NL.UTF-8
Also, I do not use Konsole, but there should be a setting in the menu somewhere that let's you set it to use UTF-8 directly. Try Settings -> Encoding -> Unicode (utf8).
Hi Blooming, many thanks for your hints! My Konsole char encoding setting is "using default: utf-8". So, in the past, I've already thinking that it is okay and never change it. After read your post, I tried to change it to GBK. On the other hand, my /etc/profile.d/lang.sh is also GBK (zh_CN.gbk). Then, after reboot X, I found Konsole works! It can display Chinese without problem! I am so happen, though I still don't understand why setting these to utf-8 did not work.

On the other hand, even urxvt can display Chinese in previous locale setting (I have to run it with 'bash -l -c urxvt'), but it font rending is really poor than Konsole. Konsole looks more nice to me.
 
Old 07-14-2013, 06:23 AM   #13
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by BloomingNutria View Post
From what I see on Google, Unicode font rendering is a common problem in Konsole. I think it is supposed to work, but isn't quite ironed out yet. Here is a bug report:

http://kde.6490.n7.nabble.com/Bug-74190-Console-Unicode-support-not-100-there-td1251526.html
The bug report you quoted is from Dec 05, 2011. Today is Jul 14, 2013.
 
Old 07-14-2013, 06:34 AM   #14
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by narke View Post
..., though I still don't understand why setting these to utf-8 did not work. ...
From your screenshot you're displaying a text file in GBK encoding as UTF-8. of course this does not work.

I think the best way to avoid encoding problems is to not use multi-byte character in C source code but use "gettext".

If you really have political problems (e.g. your boss forces you to embed Chinese in C source code), please use the UTF-8 encoding, and set your locale to zh_CN.UTF-8.
 
Old 07-14-2013, 07:00 AM   #15
narke
Member
 
Registered: Apr 2010
Posts: 197

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by guanx View Post
From your screenshot you're displaying a text file in GBK encoding as UTF-8. of course this does not work.

I think the best way to avoid encoding problems is to not use multi-byte character in C source code but use "gettext".

If you really have political problems (e.g. your boss forces you to embed Chinese in C source code), please use the UTF-8 encoding, and set your locale to zh_CN.UTF-8.
I agree 'gettext' is good choice. The problem is that I have to work with a lot of legacy code, which already have embedded Chinese characters. Anyway, thanks for your advices!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get gvim color in vim? cola Slackware 1 03-26-2010 04:19 AM
gvim or vim? Abomb Programming 28 12-14-2006 11:27 PM
prompt within gvim/vim/vi zchoyt Linux - Software 6 02-02-2005 06:30 AM
vim or gvim raees Linux - General 7 03-17-2004 05:02 PM
vim / gvim Shak Linux - Software 4 04-03-2003 09:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration