March 24, 2009

Emacs, Japanese, Putty, Windows, and text entry

I don't know why but I have had to set this up a few times now. If you try writing Japanese via Putty into Emacs, and things do not work for you (instead it looks like Emacs is interpreting things as control characters in some way) then the following magic incantation might help you:

;; Set up Japanese input and coding systems
(set-language-environment "Japanese")
(set-terminal-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(set-buffer-file-coding-system 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(set-keyboard-coding-system 'utf-8) ; This is the magic for windows putty Japanese input

The important bit is the set-keyboard-coding-system. The other things are important to some degree, but the keyboard setting is what determines whether emacs will beep at you or put up some pretty Japanese text.

I actually have Putty, Emacs, and Gnu Screen all playing nicely together now, which is great. But this is only true for version 23.x of Emacs, since 22.x doesn't seem to play well with Japanese in a terminal under screen...


Provide your email address when commenting and Gravatar will provide general portable avatars, and if you haven't signed up with them, a cute procedural avatar with their implementation of Shamus Young's Wavatars.

Re: Emacs, Japanese, Putty, Windows, and text entry
Oh man. I remember being super frustrated trying to get that to work last time.
Posted 2 weeks, 2 days ago by Matt • • wwwReply

Comments have now been turned off for this post