Search code examples
haskellunicodeutf-8ghcxmonad

Xmonad paste special character \x00f6 with pasteString?


When using Xmonad.Util.Paste I'm trying to paste a ö character with pasteString but nothing appears. How can I paste this character?

I tried to use:

 , ((mod4Mask                , xK_o      ),   pasteString "ö")

But this gave me a compilation error (which I expected): lexical error in string/character literal (UTF-8 decoding error) So I looked up the corresponding escape sequence here and tried the following line:

 , ((mod4Mask                , xK_o      ),   pasteString "\x00f6")

This compiled fine but when pressing the key combination nothing seems to appear (I tried it with a regular string and it worked fine, also pasteSelection works like intended). What am I doing wrong?

On a side note: I also tried \x00F6 but it didn't make any difference. Also I'm using ghc version 7.8.4.

Update 1:

I found this cheatsheet for haskell, so I tried the string \xC\&4 which results in ,4. When only using \&4 it results in 4 and when using \x2C it prints ,.

Update 2:

It seems like XMonad.Util.Paste doesn't work with Umlauts at all, as mentioned the function pasteSelection works. But when selecting an ö character it doesn't. So I guess I need to use xdotool or something similar.

Your help would be appreciated a lot, thanks for looking at this issue!


Solution

  • pasteString maps pasteChar over each char in the string; pasteChar, in turn, have trouble with non-ASCII characters, which is stated in the comments to the source code:

    Note that this function makes use of 'stringToKeysym', and so will probably have trouble with any 'Char' outside ASCII.

    In light of that, I suggest setting up an X Compose key, where you can type "ö" with Compose o ".