[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Coding system and environment variables
From: |
Göran Uddeborg |
Subject: |
Coding system and environment variables |
Date: |
Wed, 20 Feb 2008 09:00:05 +0100 |
How is the coding system decided when reading an environment variable?
I'm running a system using UTF-8. My locale is sv_SE.utf8. And emacs
uses UTF-8 as default most of the time. When I open a new file for
example.
I do have issues with strings coming from environment variables though.
I first discovered this in the vm mail system, since it misinterpreted
the variable MAIL which has the value /var/spool/mail/göran. (In case
your mailer mangles it, the last file name component is "g ä r a
n".) But it also causes problems with functions relating to the home
directory. HOME is /home/göran (same last component as before).
As an example, I start emacs in my home directory, and do a few
experiments in the scratch buffer (which has a "u" for coding system in
the mode line):
default-directory
"/home/göran/"
Looks good. I see my ö.
(expand-file-name "")
"/home/göran"
Ok too.
(expand-file-name "~")
"/home/g\303\266ran"
Here the octal codes for a UTF-8 encoded ö is shown instead of the
ö itself. Why is this different? The source of ~ is the
environment variable HOME. But if I explicitly ask for that variable:
(getenv "HOME")
"/home/göran"
Here I see the ö
Let's have a bit more fun. Here I try to expand a FILE with my own
name:
(expand-file-name "göran")
"/home/göran/göran"
Looks the way I would expect. Now the same thing, explicitly saying to
put it in the home directory:
(expand-file-name "~/göran")
"/home/g\xc3\xb6ran/göran"
The ö in the file name is ok. The ö in the directory name is
strange again, only this time it is shown in hex rather than octal.
Can anyone explain what is going on? And most importantly, how do I
tell emacs that environment variables are using the UTF-8 coding system?
I've read the chapter on International Character Set Support in the info
manual, but I couldn't find any help on this in there.
- Coding system and environment variables,
Göran Uddeborg <=