summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/MinXft.hsc
diff options
context:
space:
mode:
authorSibi Prabakaran <sibi@psibi.in>2020-08-09 12:21:37 +0530
committerSibi Prabakaran <sibi@psibi.in>2020-08-09 13:09:51 +0530
commit73e02934d68dfaf04bbb36dbb2e3b52b042c65bb (patch)
tree3c02f4bd6d1673f33264efd4af1c861acd1e96a9 /src/Xmobar/X11/MinXft.hsc
parent78efa5900a8670450139cfce52f30d6670ba1e09 (diff)
downloadxmobar-73e02934d68dfaf04bbb36dbb2e3b52b042c65bb.tar.gz
xmobar-73e02934d68dfaf04bbb36dbb2e3b52b042c65bb.tar.bz2
Conditional encoding of xft string
Diffstat (limited to 'src/Xmobar/X11/MinXft.hsc')
-rw-r--r--src/Xmobar/X11/MinXft.hsc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Xmobar/X11/MinXft.hsc b/src/Xmobar/X11/MinXft.hsc
index acc60b2..22edf8f 100644
--- a/src/Xmobar/X11/MinXft.hsc
+++ b/src/Xmobar/X11/MinXft.hsc
@@ -161,10 +161,16 @@ withAXftDraw d p v c act = do
foreign import ccall "XftDrawStringUtf8"
cXftDrawStringUtf8 :: AXftDraw -> AXftColor -> AXftFont -> CInt -> CInt -> Ptr (#type FcChar8) -> CInt -> IO ()
+utf8EncodeString :: Num b => String -> [b]
+utf8EncodeString str = if UTF8.isUTF8Encoded str
+ then map (fi . ord) str
+ else map fi (UTF8.encode str)
+
+
drawXftString :: (Integral a1, Integral a) =>
AXftDraw -> AXftColor -> AXftFont -> a -> a1 -> String -> IO ()
drawXftString d c f x y string =
- withArrayLen (map (fi . ord) string)
+ withArrayLen (utf8EncodeString string)
(\len ptr -> cXftDrawStringUtf8 d c f (fi x) (fi y) ptr (fi len))
drawXftString' :: AXftDraw ->