Tuesday, January 12, 2010

Unicode in an Emacs shell

My current project is a Haskell program that generates a lot of unicode that gets dumped to the screen.  I occasionally need to sift through the output. My usual method is to run a terminal in an emacs buffer (via M-x shell) and run the command line program generated from Haskell through that shell.

I was recently frustrated when I updated from Emacs 22 to Emacs 23.  While the unicode support is much better in general in Emacs 23, the shell stopped printing the unicode correctly.  After lots of false starts, I finally found that you need to run the following command:

M-x set-buffer-process-coding-system
with mule-utf-8 for both input and output.  Or add

(set-buffer-process-coding-system 'mule-utf-8 'mule-utf-8)

to the shell-mode-hook.  Then the unicode prints correctly.

1 comment:

  1. Good find...gets me host of the way there but still get some incorrectly printed characters.

    ReplyDelete