[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to keep character encoding in text file...

From: Eli Zaretskii
Subject: Re: How to keep character encoding in text file...
Date: Fri, 06 Mar 2009 12:51:17 +0200

> From: Marko Myllymaki <address@hidden>
> Date: Fri, 06 Mar 2009 09:39:56 +0200
> Eli Zaretskii wrote:
> >> 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.
> > 
> > Yes, that's how it's supposed to work, if you don't let any
> > non-Latin-1 characters creep in.
> Okay, that might be the problem... because my system defaults to UTF-8, 
> I guess that there is some keyboard input encoding in emacs which uses 
> UTF-8.

No, that shouldn't in itself be a problem, as long as the characters
your keyboard input inserts are encodable in Latin-1.

When Emacs receives keyboard input, it first decodes all the
characters into its internal representation.  After such decoding, it
no longer matters how the characters were transmitted to Emacs, only
if they have a valid encoding in Latin-1.

In other words, keyboard input encoding has no direct relation to when
Emacs decides that the original file's encoding cannot be used to save
the modified buffer.

> Therefore if I enter "baz" in latin1 buffer, everything is okay, but 
> "foobar åäö" has some UTF-8 and it then forces buffer encoding to UTF-8...

All 3 characters you cited above are encodable in Latin-1, so this
cannot be the problem.  You need to find out (e.g., by using the 
"C-u C-x =" command on suspect characters) which one of the characters
you typed cannot be encoded in Latin-1.

Which Emacs version is that, by the way?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]