unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Coding system and environment variables
@ 2008-02-20  8:00 Göran Uddeborg
  2008-02-20 15:41 ` Sven Joachim
  2008-02-20 16:23 ` Piet van Oostrum
  0 siblings, 2 replies; 5+ messages in thread
From: Göran Uddeborg @ 2008-02-20  8:00 UTC (permalink / raw)
  To: help-gnu-emacs

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-21 10:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-20  8:00 Coding system and environment variables Göran Uddeborg
2008-02-20 15:41 ` Sven Joachim
2008-02-21 10:10   ` Göran Uddeborg
2008-02-20 16:23 ` Piet van Oostrum
2008-02-21 10:14   ` Göran Uddeborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).