Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Solved: Locale issue for Konsole under KDE
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
weiypan_us
Tux's lil' helper
Tux's lil' helper


Joined: 25 Feb 2017
Posts: 109

PostPosted: Fri Jul 05, 2019 10:26 pm    Post subject: Solved: Locale issue for Konsole under KDE Reply with quote

Hi I need help on locale to display Chinese characters under Konsole under KDE

my locale output is
Code:
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

It will display garbled characters for Chinese like
æ°å å¡å¯æ»çå°è¾¾æ就中åé®é¢å西æ¹æ°é»èªç±å½ä¼ç¾è¾±BBC主æ人-vNIvCz-e_jw.mkv

[Moderator edit: added [code] tags to preserve output layout. -Hu]


Last edited by weiypan_us on Sun Jul 07, 2019 12:44 am; edited 1 time in total
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Fri Jul 05, 2019 11:14 pm    Post subject: Reply with quote

  1. Which font is configured in Konsole? Does it support Chinese characters?

  2. Please post the contents of the file '/etc/locale.conf'

  3. Please post the contents of the file '/etc/locale.gen'

  4. Please post the output of
    Code:
    locale -a

    and of
    Code:
    eselect locale list


Back to top
View user's profile Send private message
weiypan_us
Tux's lil' helper
Tux's lil' helper


Joined: 25 Feb 2017
Posts: 109

PostPosted: Fri Jul 05, 2019 11:25 pm    Post subject: Reply with quote

Hi mike155,

mike155 wrote:
  1. Which font is configured in Konsole? Does it support Chinese characters?

  2. Please post the contents of the file '/etc/locale.conf'

  3. Please post the contents of the file '/etc/locale.gen'

  4. Please post the output of
    Code:
    locale -a

    and of
    Code:
    eselect locale list




1. Which font is configured in Konsole? Does it support Chinese characters? I don't know how to check
2. I don't have /etc/locale.conf
3. cat /etc/locale.gen
Code:
blk161@asus ~ $ cat /etc/locale.gen
# /etc/locale.gen: list all of the locales you want to have on your system.
# See the locale.gen(5) man page for more details.
#
# The format of each line:
# <locale name> <charset>
#
# Where <locale name> starts with a name as found in /usr/share/i18n/locales/.
# It must be unique in the file as it is used as the key to locale variables.
# For non-default encodings, the <charset> is typically appended.
#
# Where <charset> is a charset located in /usr/share/i18n/charmaps/ (sans any
# suffix like ".gz").
#
# All blank lines and lines starting with # are ignored.
#
# For the default list of supported combinations, see the file:
# /usr/share/i18n/SUPPORTED
#
# Whenever glibc is emerged, the locales listed here will be automatically
# rebuilt for you.  After updating this file, you can simply run `locale-gen`
# yourself instead of re-emerging glibc.

en_CA.UTF-8 UTF-8
en_US.UTF-8 UTF-8
en_US ISO-8859-1
zh_CN.GB18030 GB18030
zh_CN.GBK GBK
zh_CN.UTF-8 UTF-8
zh_CN GB2312
   

4.
Code:
$ locale -a
C
C.utf8
en_CA.utf8
en_US
en_US.iso88591
en_US.utf8
POSIX
zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8

5.
Code:
$ eselect locale list
Available targets for the LANG variable:
  [1]   C
  [2]   C.utf8
  [3]   en_CA.utf8
  [4]   en_US
  [5]   en_US.iso88591
  [6]   en_US.utf8 *
  [7]   POSIX
  [8]   zh_CN
  [9]   zh_CN.gb18030
  [10]  zh_CN.gb2312
  [11]  zh_CN.gbk
  [12]  zh_CN.utf8
  [ ]   (free form)


[Moderator edit: added [code] tags to preserve output layout. -Hu]
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Fri Jul 05, 2019 11:51 pm    Post subject: Reply with quote

Thanks for your data.
  1. In Konsole, in the menu bar: open "Settings" / "Edit Current Profile". Click on "Appearance" and on "Color scheme & font". There's a text field "font". Which font is selected?

  2. In Konsole, in the menu bar:: open "Settings" / "Edit Current Profile". Click on "Advanced". There's a selection box "Default character encoding". It must be set to "UTF-8". Is it?

  3. Enter the lines below in a Konsole window:
    Code:
    cd /
    ls -la

    You will see a directory listing with dates and times in US-American format, right?

  4. Now enter:
    Code:
    export LANG="zh_CN.UTF-8"
    ls -la

    What do you see? There should be a directory listing with dates and times in Chinese format. Each line should contain at least one Chinese character (月). Do you see it? Or do you see garbled output?
Back to top
View user's profile Send private message
weiypan_us
Tux's lil' helper
Tux's lil' helper


Joined: 25 Feb 2017
Posts: 109

PostPosted: Sat Jul 06, 2019 3:37 am    Post subject: Reply with quote

1. In Konsole, in the menu bar: open "Settings" / "Edit Current Profile". Click on "Appearance" and on "Color scheme & font". There's a text field "font". Which font is selected? Hack

2. In Konsole, in the menu bar:: open "Settings" / "Edit Current Profile". Click on "Advanced". There's a selection box "Default character encoding". It must be set to "UTF-8". Is it? ISO-8859-1

3. Enter the lines below in a Konsole window:
Quote:
$ cd /
$ ls -la
total 239
drwxr-xr-x 25 root root 4096 May 18 20:32 .
drwxr-xr-x 25 root root 4096 May 18 20:32 ..
drwxr-xr-x 2 root root 4096 Jun 14 18:29 bin
drwxr-xr-x 4 root root 3072 May 26 21:24 boot
drwxr-xr-x 18 root root 4540 Jul 4 14:42 dev
drwxrwxrwt 27 root root 4096 Feb 24 22:43 DVD
drwxr-xr-x 104 root root 4096 Jun 29 21:01 etc
drwxr-xr-x 8 root root 4096 Feb 19 2017 home
lrwxrwxrwx 1 root root 5 May 18 20:31 lib -> lib64
drwxr-xr-x 3 root root 4096 May 18 20:32 lib32
drwxr-xr-x 16 root root 12288 Jun 14 18:29 lib64
drwx------ 2 root root 16384 Jul 14 2014 lost+found
drwxr-xr-x 8 root root 4096 May 4 20:14 media
drwxr-xr-x 4 root root 4096 Aug 15 2014 mnt
drwxr-xr-x 2 root root 4096 Mar 8 2017 mnt_weipan
drwxr-xr-x 6 root root 4096 Jun 22 16:47 opt
dr-xr-xr-x 265 root root 0 Jun 29 21:01 proc
drwx------ 14 root root 4096 Jun 30 23:20 root
drwxr-xr-x 27 root root 1020 Jun 30 03:40 run
drwxr-xr-x 2 root root 12288 Jun 14 18:29 sbin
dr-xr-xr-x 12 root root 0 Jun 29 21:01 sys
drwxr-xr-x 2 root root 4096 Sep 30 2014 t
drwxrwxrwt 9 blk161 blk161 131072 Jul 5 22:13 tmp
drwxr-xr-x 14 root root 4096 Dec 29 2016 usr
drwxr-xr-x 13 root root 4096 Apr 29 01:57 var
drwxr-xr-x 2 root root 4096 Mar 3 2015 z


4. Now enter:
Quote:
$ export LANG="zh_CN.UTF-8"
$ ls -la
total 239
drwxr-xr-x 25 root root 4096 5æ 18 20:32 .
drwxr-xr-x 25 root root 4096 5æ 18 20:32 ..
drwxr-xr-x 2 root root 4096 6æ 14 18:29 bin
drwxr-xr-x 4 root root 3072 5æ 26 21:24 boot
drwxr-xr-x 18 root root 4540 7æ 4 14:42 dev
drwxrwxrwt 27 root root 4096 2æ 24 22:43 DVD
drwxr-xr-x 104 root root 4096 6æ 29 21:01 etc
drwxr-xr-x 8 root root 4096 2æ 19 2017 home
lrwxrwxrwx 1 root root 5 5æ 18 20:31 lib -> lib64
drwxr-xr-x 3 root root 4096 5æ 18 20:32 lib32
drwxr-xr-x 16 root root 12288 6æ 14 18:29 lib64
drwx------ 2 root root 16384 7æ 14 2014 lost+found
drwxr-xr-x 8 root root 4096 5æ 4 20:14 media
drwxr-xr-x 4 root root 4096 8æ 15 2014 mnt
drwxr-xr-x 2 root root 4096 3æ 8 2017 mnt_weipan
drwxr-xr-x 6 root root 4096 6æ 22 16:47 opt
dr-xr-xr-x 265 root root 0 6æ 29 21:01 proc
drwx------ 14 root root 4096 6æ 30 23:20 root
drwxr-xr-x 27 root root 1020 6æ 30 03:40 run
drwxr-xr-x 2 root root 12288 6æ 14 18:29 sbin
dr-xr-xr-x 12 root root 0 6æ 29 21:01 sys
drwxr-xr-x 2 root root 4096 9æ 30 2014 t
drwxrwxrwt 9 blk161 blk161 131072 7æ 5 22:13 tmp
drwxr-xr-x 14 root root 4096 12æ 29 2016 usr
drwxr-xr-x 13 root root 4096 4æ 29 01:57 var
drwxr-xr-x 2 root root 4096 3æ 3 2015 z



There is no Chinese characters, they are garbled output in the date column.[/code]
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Jul 06, 2019 10:32 am    Post subject: Reply with quote

Please set your character encoding in Konsole to UTF-8:
  • Open "Settings" / "Edit Current Profile". Click on "Advanced". There's a selection box "Default character encoding". Choose "Unicode" / "UTF-8".

Then re-try:
Code:
export LANG="zh_CN.UTF-8"
ls -la

Do you see the Chinese character (月) now?
Back to top
View user's profile Send private message
weiypan_us
Tux's lil' helper
Tux's lil' helper


Joined: 25 Feb 2017
Posts: 109

PostPosted: Sat Jul 06, 2019 6:41 pm    Post subject: Reply with quote

Hi mike155, it works now.

blk161@asus / $ export LANG="zh_CN.UTF-8"
blk161@asus / $ ls -l
total 231
drwxr-xr-x 2 root root 4096 6月 14 18:29 bin
drwxr-xr-x 4 root root 3072 5月 26 21:24 boot
drwxr-xr-x 18 root root 4540 7月 4 14:42 dev
drwxrwxrwt 27 root root 4096 2月 24 22:43 DVD
drwxr-xr-x 104 root root 4096 6月 29 21:01 etc
drwxr-xr-x 8 root root 4096 2月 19 2017 home
lrwxrwxrwx 1 root root 5 5月 18 20:31 lib -> lib64
drwxr-xr-x 3 root root 4096 5月 18 20:32 lib32
drwxr-xr-x 16 root root 12288 6月 14 18:29 lib64
drwx------ 2 root root 16384 7月 14 2014 lost+found
drwxr-xr-x 8 root root 4096 5月 4 20:14 media
drwxr-xr-x 4 root root 4096 8月 15 2014 mnt
drwxr-xr-x 2 root root 4096 3月 8 2017 mnt_weipan
drwxr-xr-x 6 root root 4096 6月 22 16:47 opt
dr-xr-xr-x 250 root root 0 6月 29 21:01 proc
drwx------ 14 root root 4096 6月 30 23:20 root
drwxr-xr-x 27 root root 1020 6月 30 03:40 run
drwxr-xr-x 2 root root 12288 6月 14 18:29 sbin
dr-xr-xr-x 12 root root 0 6月 29 21:01 sys
drwxr-xr-x 2 root root 4096 9月 30 2014 t
drwxrwxrwt 9 blk161 blk161 131072 7月 6 14:37 tmp
drwxr-xr-x 14 root root 4096 12月 29 2016 usr
drwxr-xr-x 13 root root 4096 4月 29 01:57 var
drwxr-xr-x 2 root root 4096 3月 3 2015 z
blk161@asus / $
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Jul 06, 2019 6:54 pm    Post subject: Reply with quote

Great! :-)

Please keep in mind:
  1. Use
    Code:
    eselect locale list
    and
    Code:
    eselect locale set <N>

    to select the default output language and encoding of your applications

  2. Unless you have very specific and strong reasons, choose "UTF-8" as encoding

  3. The encoding of your terminal (Konsole, xterm, PuTTY, whatever you use) must match the encoding you selected with 'eselect locale'
Back to top
View user's profile Send private message
weiypan_us
Tux's lil' helper
Tux's lil' helper


Joined: 25 Feb 2017
Posts: 109

PostPosted: Sun Jul 07, 2019 12:44 am    Post subject: Reply with quote

mike155 wrote:
Great! :-)

Please keep in mind:
  1. Use
    Code:
    eselect locale list
    and
    Code:
    eselect locale set <N>

    to select the default output language and encoding of your applications

  2. Unless you have very specific and strong reasons, choose "UTF-8" as encoding

  3. The encoding of your terminal (Konsole, xterm, PuTTY, whatever you use) must match the encoding you selected with 'eselect locale'


mike155,

Thank you!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments 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