From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?G=F6ran?= Uddeborg Newsgroups: gmane.emacs.help Subject: Coding system and environment variables Date: Wed, 20 Feb 2008 09:00:05 +0100 Organization: Jeppesen Systems AB Message-ID: <1203494405.25030.9.camel@gora.got.jeppesensystems.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1203550544 20222 80.91.229.12 (20 Feb 2008 23:35:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 Feb 2008 23:35:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 21 00:36:09 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JRyTn-0001pN-9h for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Feb 2008 00:35:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRyTI-00028V-2A for geh-help-gnu-emacs@m.gmane.org; Wed, 20 Feb 2008 18:35:28 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsfeed1.swip.net!swipnet!gatekeeper.carmen.se!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 60 Original-NNTP-Posting-Host: gora.got.jeppesensystems.com Original-X-Trace: rifle.carmen.se 1203494405 26177 192.168.98.33 (20 Feb 2008 08:00:05 GMT) Original-X-Complaints-To: newsmaster@carmen.se Original-NNTP-Posting-Date: Wed, 20 Feb 2008 08:00:05 +0000 (UTC) X-Mailer: Evolution 2.8.0 (2.8.0-40.el5) Original-Xref: shelby.stanford.edu gnu.emacs.help:156326 X-Mailman-Approved-At: Wed, 20 Feb 2008 18:35:06 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:51708 Archived-At: 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=C3=B6ran. (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=C3=B6ran (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=C3=B6ran/" Looks good. I see my ö. (expand-file-name "") "/home/g=C3=B6ran" 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=C3=B6ran" 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=C3=B6ran") "/home/g=C3=B6ran/g=C3=B6ran" Looks the way I would expect. Now the same thing, explicitly saying to put it in the home directory: (expand-file-name "~/g=C3=B6ran") "/home/g\xc3\xb6ran/g=C3=B6ran" 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.