[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to keep character encoding in text file...
From: |
Pascal J. Bourguignon |
Subject: |
Re: How to keep character encoding in text file... |
Date: |
Thu, 05 Mar 2009 14:33:48 +0100 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) |
Marko Myllymaki <firstname.lastname@iki.fi> writes:
> I usually work with UTF-8 encoded files and my system is set up for
> UTF-8 (text may be in english, finnish, swedish, german, russian...)
>
> However, sometimes I edit latin1 -encoded files and I would like to
> have the encoding automatically kept that way when saving files. Now
> it seems to change unwantedly to UTF-8 sometimes... I have to use
> iconv command line tool to change this...
>
> So... if I load UTF-8 encoded file, emacs always saves it that way. If
> I open latin1-encoded file, it should keep it in the original
> encoding.
I don't know if there's an easy way to do that.
> Maybe something to put in .emacs to achieve this...
The easiest way is to put a comment on the first two lines containing:
-*- coding:iso-8859-1 -*-
Alternatively, you could put a comment in the last 512 bytes of the file
containing:
Local Variables:
codingl iso-8859-1
End:
Otherwise, you may use the file extension, or the file location (or
really any regexp on the file path) to determine the encoding,
customizing the file-coding-system-alist variable.
(push '("^/some/dir/latin-1-files/.*" iso-8859-1 . iso-8859-1)
file-coding-system-alist)
(push '("\\.iso-8859-1$" iso-8859-1 . iso-8859-1)
file-coding-system-alist)
--
__Pascal Bourguignon__