Re: [dwm] What am I doing wrong with displaying utf-8 string?

From: Anselm R Garbe <>
Date: Mon, 18 Aug 2008 09:32:01 +0100


2008/8/6 Christian Garbs <>:
> I'm still using dwm-4.7 and with the following two patches everything
> is alright for me (should be applicable to current dwm, too):
> Both
> $ xtermset -title 日本語
> $ { echo 猫; echo 犬; echo 何; } | dmenu
> are handled and displayed correctly by dwm and dmenu.
> I use the font "-misc-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*" in dwm and
> "-misc-fixed-medium-r-*-*-13-*-*-*-*-*-*-*" in dmenu (should really be the
> same, I should add the "normal" to dmenu for consistency).

Xutf8* should be used if the locale is not UTF-8 but the string which
is going to be rendered is UTF-8 encoded. In contrast to this, Xmb*
should be used if all strings are expected being encoded by the locale
in use. Xmb* not only works for UTF-8 encodings but also for all
others, that's why Xutf8* is not necessary at all if users use some
UTF-8 locale, which is nearly the standard now (except for some BSDs).

So I had a recheck into the dmenu/dwm code and concluded that the
setlocale() call is unnecessary since it only checks if a locale is
set. If we would use Xutf8* we would need to check something like
if(strstr(setlocale(LC_CTYPE, ""), "UTF-8")) ... to make sure we don't
render garbage. However this is not necessary for Xmb* unless X isn't

Old-style X font handling is poorly maintained unfortunately nowadays,
because all GTK/KDE fanboys are using Xft instead, which is no option
yet, because it is badly designed and depends on a huge pile of crap.

So I have to repeat what I told several times: try to find a proper
font configuration if you need support for special character sets or
fallback to a non-UTF-8 locale if you are CJK user or maybe if
cyrillic glyphs are your favorite alphabet.

Kind regards,
Received on Mon Aug 18 2008 - 08:32:01 UTC

This archive was generated by hypermail 2.2.0 : Mon Aug 18 2008 - 08:36:03 UTC