GNU Emacs and UTF-8 locale
I recently wanted to shift to a UTF-8 locale, because I wanted to play with stuff like writing in Arabic, and because it seems to be the road forward.
So I switched and GNU Emacs starts to enter garbage in my buffers. I type “æøåÆØÅ é퀓, but Emacs gives me “æøåÃÃà éÃ⬓. Ever so slightly less useful, and less readable too.
I tried fiddling with “Options | Mule | Language Environments” and “Options | Mule | Set Coding System”, but to no avail.
Somewhat deluded I gave up and went back to Latin 1, mostly at least. Every once in a while I tried again, and one day I stumbled over a reference to the Emacs file etc/PROBLEMS, a section on problems with UTF-8 support in GNU Emacs. Unfortunately the section was gone from my copy, but I found it on the net.
The solution to all my problems: add the following lines to ~/.emacs:
(setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8)
The problem went away and haven’t been seen since.
BTW, I’m using GNU Emacs 21.3.1, installed from Debian testing and unstable (tried them both).
Tags: Linux
October 20th, 2004 at 10:05 pm
Awesome. Thanks. works also for french keyboards
December 10th, 2004 at 9:54 pm
That’s it… thanks a lot.
January 3rd, 2005 at 12:14 am
nearly works : except when i type stuff like "î" (or any compose char). This locks emacs. Looks like "î" is interpreted as a command as it’s displayed in the status bar …
February 10th, 2005 at 5:33 pm
For Google indexing:
This page explains how to solve the problem of pasting accents and accented characters from emacs to mozilla firefox.
How to paste accents from emacs to firefox.
Comment copier-coller des accents de emacs vers firefox.
Wie man Umlauts von emacs zum firefox pasted.
April 30th, 2005 at 6:10 pm
Got it working after some trouble – turns out I had (standard-display-european t) in my .emacs which needed removing.
October 26th, 2005 at 7:25 am
This solved problems with UTF-8 characters in Emacs term and ansi-term.
Tio solvis problemojn pri UTF-8-literoj en
Emakso-term kaj ansi-term.
February 28th, 2006 at 7:00 pm
I just tried this in Emacs in Windows. And it looks like it thinks that every ÆØÅ is a command now. I made a clean _emacs file. So unless there is something else I don’t know it is loading in Windows, then it should have been pretty stright forward, but no..:(
February 12th, 2007 at 4:06 pm
I experienced the same problem as Østlund and found that if I just removed the (set-keyboard-coding-system ‘utf-8) line, everything works like a charm.
Thanks for the help – would never have known where to start by myself!
March 15th, 2007 at 3:55 pm
Thank you. Same problem with Swedish äåö in emacs on Debian, must have utf-8. Killed two days for that. Now it seems to work. Thanks for sharing info!