
Hi folks, I'm using xmobar as my status bar and have problems to get UTF8 characters to display correctly. I did the following tests: 1. Start xmobar, reading input from stdin. Type in some unicode characters. Xmobar displays them fine. 2. Add some unicode characters to my loghook in xmonad. Things come out garbled. 3. Instead of piping to xmobar, make xmonad write to a file. The file contents are also garbled. To be more precise, they are exactly what xmobar shows me in the second test. So this seems like the problem is on xmonad's end, not xmobar's. I'm running the latest darcs version of xmonad. Any ideas what could be causing this? Thanks, Norbert

Hi Norbet,
Which version of xmobar are you using?
In previous versions of xmonad-contrib, utf-8 support was optional;
since 0.9.1 it has been mandatory (and hence your version of xmonad
should support it).
However, in xmobar it is still only optional and needs to be built with
--flags=with_utf8 for utf-8 support.
I use xmobar with darcs xmonad (and contrib) and utf-8 works fine; here
is what I use:
,----
| myLogHook panel = do dynamicLogWithPP $ ivanmPP { ppOutput = hPutStrLn panel }
|
| ivanmPP :: PP
| ivanmPP = defaultPP { ppCurrent = xmobarColor "green" "" . wrap "[" "]" . addIndex
| , ppVisible = xmobarColor "blue" "" . wrap "(" ")" . addIndex
| , ppHidden = addIndex
| , ppHiddenNoWindows = xmobarColor "tan" "" . addIndex
| , ppUrgent = xmobarColor "red" "black" . pad
| , ppLayout = xmobarColor "sienna" ""
| , ppSep = pad $ xmobarColor "VioletRed" "" "※"
| , ppWsSep = xmobarColor "gray" "" $ pad "Ѻ"
| , ppTitle = xmobarColor "green" "" . shorten 40
| , ppExtras = maildirs
| , ppOrder = \ (ws:l:_:es) -> ws : l : es
| }
| where
| addIndex x = (show . (+1) . fromJust . findIndex (x==)) myWorkspaces ++ " : " ++ x
|
| maildirs = map ($ "/home/ivan/Maildir/") [maildirUnread, maildirNew]
`----
In case you can't see them, there are utf-8 characters in ppSep and ppWsSep.
Norbert Zeh
Hi folks,
I'm using xmobar as my status bar and have problems to get UTF8 characters to display correctly. I did the following tests:
1. Start xmobar, reading input from stdin. Type in some unicode characters. Xmobar displays them fine.
2. Add some unicode characters to my loghook in xmonad. Things come out garbled.
3. Instead of piping to xmobar, make xmonad write to a file. The file contents are also garbled. To be more precise, they are exactly what xmobar shows me in the second test.
So this seems like the problem is on xmonad's end, not xmobar's. I'm running the latest darcs version of xmonad. Any ideas what could be causing this?
Thanks, Norbert _______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Wed, Apr 28, 2010 at 1:11 PM, Norbert Zeh
Hi folks,
I'm using xmobar as my status bar and have problems to get UTF8 characters to display correctly. I did the following tests:
1. Start xmobar, reading input from stdin. Type in some unicode characters. Xmobar displays them fine.
2. Add some unicode characters to my loghook in xmonad. Things come out garbled.
3. Instead of piping to xmobar, make xmonad write to a file. The file contents are also garbled. To be more precise, they are exactly what xmobar shows me in the second test.
So this seems like the problem is on xmonad's end, not xmobar's. I'm running the latest darcs version of xmonad. Any ideas what could be causing this?
What version of GHC do you use? Starting from version 6.12 GHC properly encodes strings. Earlier versions just truncated characters to 0-255 range. If you use GHC 6.10 or earlier you should use encodeString from utf8-string package to encode string in utf8 before writing to pipe.

Alexey Khudyakov [2010.04.28 1518 +0400]:
On Wed, Apr 28, 2010 at 1:11 PM, Norbert Zeh
wrote: Hi folks,
I'm using xmobar as my status bar and have problems to get UTF8 characters to display correctly. I did the following tests:
1. Start xmobar, reading input from stdin. Type in some unicode characters. Xmobar displays them fine.
2. Add some unicode characters to my loghook in xmonad. Things come out garbled.
3. Instead of piping to xmobar, make xmonad write to a file. The file contents are also garbled. To be more precise, they are exactly what xmobar shows me in the second test.
So this seems like the problem is on xmonad's end, not xmobar's. I'm running the latest darcs version of xmonad. Any ideas what could be causing this?
What version of GHC do you use? Starting from version 6.12 GHC properly encodes strings. Earlier versions just truncated characters to 0-255 range.
If you use GHC 6.10 or earlier you should use encodeString from utf8-string package to encode string in utf8 before writing to pipe.
Thanks Alex and Ivan, before I say anything more on the issue, I need to do a bit more tinkering to find out what's really wrong. I'm running darcs xmonad and darcs xmobar, compiled with GHC 6.12.1. So the utf8 flag for xmobar should have no effect. (I tried with and without, and the result is the same.) What I've found out so far is (1) xmonad seems to double-encode the utf string. Namely, if I change my ppOutput to hPutStrLn handle . UTF8.decodeString, things come out *kind of* fine. (2) By *kind of* in the previous point, I mean that characters like accented letters, which were mangled before, now show up just fine. However, some other characters, like arrows, come out messed up, and for this the problem seems to be at xmobar's end because the same happens if I pipe these characters into xmobar from an xterm. In case, you're wondering: yes, the characters I'm trying to display are in the font I'm using. I want to play around a little more to dig into the second issue, but the first one is certainly strange. Cheers, Norbert

В сообщении от 29 апреля 2010 09:30:22 Norbert Zeh написал:
(1) xmonad seems to double-encode the utf string. Namely, if I change my ppOutput to hPutStrLn handle . UTF8.decodeString, things come out *kind of* fine.
Yes, it does. Actual culprits are functions from XMonad.Util.Font decodeInput and encodeInput they are encoding string as UTF8 and them GHC encode it second time. I think that right fix is to use preprocessor do define them differently for GHC<=6.10 and GHC>=6.12. A bit ugly but should work for everyone.

В сообщении от 29 апреля 2010 09:30:22 Norbert Zeh написал:
(1) xmonad seems to double-encode the utf string. Namely, if I change my ppOutput to hPutStrLn handle . UTF8.decodeString, things come out *kind of* fine.
Here is patch to fix this. It does work with GHC6.12 but I couldn't test it with 6.10 or older

В сообщении от 29 апреля 2010 15:29:20 вы написали:
В сообщении от 29 апреля 2010 09:30:22 Norbert Zeh написал:
(1) xmonad seems to double-encode the utf string. Namely, if I change my ppOutput to hPutStrLn handle . UTF8.decodeString, things come out *kind of* fine.
Here is patch to fix this. It does work with GHC6.12 but I couldn't test it with 6.10 or older
Ooops. This patch breaks non-ASCII input in Promt

* On Thursday, April 29 2010, Khudyakov Alexey wrote:
В сообщении от 29 апреля 2010 15:29:20 вы написали:
В сообщении от 29 апреля 2010 09:30:22 Norbert Zeh написал:
(1) xmonad seems to double-encode the utf string. Namely, if I change my ppOutput to hPutStrLn handle . UTF8.decodeString, things come out *kind of* fine.
Here is patch to fix this. It does work with GHC6.12 but I couldn't test it with 6.10 or older
Ooops. This patch breaks non-ASCII input in Promt
Here are some guidelines for addressing encoding issues: http://code.google.com/p/xmonad/issues/detail?id=348 -- Adam

Khudyakov Alexey [2010.04.29 1720 +0400]:
В сообщении от 29 апреля 2010 15:29:20 вы написали:
В сообщении от 29 апреля 2010 09:30:22 Norbert Zeh написал:
(1) xmonad seems to double-encode the utf string. Namely, if I change my ppOutput to hPutStrLn handle . UTF8.decodeString, things come out *kind of* fine.
Here is patch to fix this. It does work with GHC6.12 but I couldn't test it with 6.10 or older
Well, the easier patch at the moment seems to be not to call encodeOutput in DynamicLog.hs. This doesn't seem to break anything else. However, now here's a problem with xmobar, which rather seems to be an X11 problem. Certain characters (e.g. \x2192 (right arrow)) still get mangled. I was able to verify that they are still intact immediately before xmobar calls wcDrawImageString to render them on screen. So something must be going wrong inside wcDrawImageString. N.

Norbert Zeh [2010.04.30 0930 -0300]:
Khudyakov Alexey [2010.04.29 1720 +0400]:
В сообщении от 29 апреля 2010 15:29:20 вы написали:
В сообщении от 29 апреля 2010 09:30:22 Norbert Zeh написал:
(1) xmonad seems to double-encode the utf string. Namely, if I change my ppOutput to hPutStrLn handle . UTF8.decodeString, things come out *kind of* fine.
Here is patch to fix this. It does work with GHC6.12 but I couldn't test it with 6.10 or older
Well, the easier patch at the moment seems to be not to call encodeOutput in DynamicLog.hs. This doesn't seem to break anything else.
However, now here's a problem with xmobar, which rather seems to be an X11 problem. Certain characters (e.g. \x2192 (right arrow)) still get mangled. I was able to verify that they are still intact immediately before xmobar calls wcDrawImageString to render them on screen. So something must be going wrong inside wcDrawImageString.
Further to the point, the same problem happens with wcDrawImageString inside xmonad. I just added \x2192 to the run-or-raise prompt in XMonadContrib, recompiled, and I get the same garbled output as in xmobar. Yet, xterm and emacs display the character fine, using exactly the same font as I use for xmonad's prompts and for xmobar. N.
participants (5)
-
Adam Vogt
-
Alexey Khudyakov
-
Ivan Lazar Miljenovic
-
Khudyakov Alexey
-
Norbert Zeh