Search code examples
encodingutf-8mutt

handling string encoding from mutt to abook


I noticed that abook, a popular mutt address book, doesn't handle differently encoded strings from mutt properly. Specifically:

# .muttrc
macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"

output from a couple of senders as seen in abook (names only):

=?iso-2022-jp?B?GyRCNF
=?ISO-2022-JP?B?GyRCPj
=?UTF-8?B?5paw55SwIOS4

It looks like the encoding is specified, but it's not properly being read through. mutt confirms charset="utf-8", and my locale/system are consistently set to utf-8. abook displays non-English/Western characters just fine in its menus and help. Something is happening exactly in between.

Is there a quick way to process the encoding through the macro? Can python/ruby be called to convert or something?


Solution

  • If abook cannot handle the encoded headers, then you should probably send them decoded to it by setting the $pipe_decode variable before doing the pipe and restoring the value just after:

    macro index,pager A "<enter-command>set my_pipe_decode=\$pipe_decode pipe_decode<return><pipe-message>abook --add-email-quiet<return><enter-command>set pipe_decode=\$my_pipe_decode; unset my_pipe_decode<return>" "add the sender address to abook"