18

Background:

  • I have some unicode characters in my prompt (git status markers essentially)
  • I'm running urxvt under xfce on arch linux.
  • I'm using DejaVu Sans Mono for Powerline font, specified via .Xresources line:

    URxvt*font: xft:DejaVu Sans Mono for Powerline:pixelsize=14

When I start urxvt the unicode characters do not render correctly.

For example

● renders as â

However, if I then start a new urxvt from inside the first terminal everything renders correctly.

There doesn't appear to be any difference in the environment between the two terminals.

What could be the difference between the first invocation and the nested invocation? I suspect the font is not correct in the 'outer' instance, but I'm unsure how to check the font of a running X window

UPDATE: It seems that the locale is not correctly set up in the app launcher for xfce4, but presumably the shell inside the first terminal inits it's own locale, meaning that both shells have the same locale.

adding

export LANG=en_GB.UTF-8

to .xinitrc before xfce4 is started seems to fix it. I suspect this isn't the correct way, but it works well enough for me.

screenshot demonstrates the problem:

enter image description here

Note: I moved this question from serverfault.com - i hope this site is more appropriate

  • How do you start X? How do you start "the first" terminal? It seems that the environment is different for these two. – Ярослав Рахматуллин Nov 24 '12 at 17:24
  • Try to run LC_ALL=ru_RU.utf8 urxvt from the current X session. If the Russian (and other Unicode) chars became correct you are in case when your environment have been running under C locale. So check locale settings for xfce. For example if you are started it in .xinitrc try to set locale before run like LANG=ru_RU.utf8 exec startxfce4. – Alexander I.Grafov Feb 24 '18 at 20:07
12

I am not entirely certain what the cause of the problem is, but the steps below might help:

  1. Confirm that the locale is set up properly

    $ 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=en_US.UTF-8
    
  2. Enable the desired locales in /etc/locale.gen and run locale-gen

    $ cat /etc/locale.gen |grep UTF
    en_US.UTF-8 UTF-8
    nb_NO.UTF-8 UTF-8
    ru_RU.UTF-8 UTF-8
    
  3. Make sure that the desired font can be loaded

    $ xset +fp /usr/share/fonts/cyrillic
    $ fc-cache
    $ fc-list # to check

  4. Apply the settings from .Xdefaults (or similar) before starting the "first terminal"
    xrdb ~/.Xdefaults

  • This is definitely to do with locale (see my update to the question), so accepting this answer as it pointed me in the correct direction. Thnks. – sw1nn Nov 29 '12 at 19:31
  • Its usually not a terrible idea to put locale settings in ~/.bash_profile (~/.zprofile), but ~/.xinitrc would work too. – Ярослав Рахматуллин Nov 29 '12 at 19:35
  • if i login on a virtual terminal (ie. without X) it all works. The shell bit is working fine, it's specific to X – sw1nn Nov 29 '12 at 19:39
  • Probably because X (or startxfce) is started from a non-login shell that does not read LANG & co from a profile. For bash, ~/.bashrc can be used to set stuff for non-login shells. But like I said, there is nothing wrong with leaving your locale settings and other variables in ~/.xinitrc. – Ярослав Рахматуллин Nov 29 '12 at 19:50
  • This problem can also affect all characters due to the letter spacing being too close. For instance, set URxvt.letterSpace: -10 and all characters display as boxes – DavisDude Jun 15 '17 at 4:10
0

For me it was a problem with powerline glyphs in urxvt. Just found out that setting the locale with localectl set-locale LANG=en_AU.UTF-8 fixes the problem for me, with the terminess powerline font at least (haven't tried other fonts)

urxvt powerline symbols

It wasn't working with en_US.UTF-8, I'm pretty sure because I can reproduce it... now that's strange... but it works now.

source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.