Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: utf-8 and zsh

On Sun, 7 Dec 2008, MaurÃcio wrote:


Is there some zsh-specific way to enter utf-8 characters? Or should I rely on my terminal to do that (xterm, mlterm etc.)?

There are two ZLE widgets related to entering special characters: insert-composed-char and insert-unicode-char

To use them, put this somewhere in your Zsh startup files:

autoload insert-composed-char
zle -N insert-composed-char
# bind it to some key (Ctrl+x in this example)
bindkey ^X insert-composed-char

autoload insert-unicode-char
zle -N insert-unicode-char
bindkey ^Y insert-unicode-char

Then, the key sequence: ^X e ' creates Ã, for example. See man zshall for
the full list. (search for insert-composed-char)

NB. On my system, though, it doesn't appear to be fully working (Both ^X
i ` and ^X i ' produce à (even though the latter should produce Ã))

For an arbitrary Unicode point, you do:
^Y e 9 ^Y (Ã)
^Y 2 0 1 9 ^Y (â)
(That is: whatever-you-bound-it-to, the code in hexadecimal, then the
bound key again.)

Really, though, I've only found these useful outside of X11. Recent
things I've read say that X11 Input Methods are preferred to X11
Compose. But, I've found that Compose is what works best for me (a
native English speaker -- so, I only rarely need accented/other chars).

With Compose, for example, I can type Compose-key (which I've mapped to
'Menu'), e ', and get Ã. The sequences mostly seem logical (compose a e
= Ã), and there are a lot of them.

(I actually made a custom keyboard map, which also puts some of the ones
I use most frequently as AltGr keys.)


Messages sorted by: Reverse Date, Date, Thread, Author