* switch between utf-8 and latin-1
@ 2009-07-18 17:44 ?manu*
2009-07-18 17:59 ` Pascal J. Bourguignon
0 siblings, 1 reply; 7+ messages in thread
From: ?manu* @ 2009-07-18 17:44 UTC (permalink / raw)
To: help-gnu-emacs
. what method does emacs use to guess the encoding of a text file?
. what is the command to tell emacs that the file in the buffer is utf-8
instead of latin-1?
. is it possible to insert some text in the file (in comments)
to tell emacs which encoding to use?
thanks,
E.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: switch between utf-8 and latin-1
2009-07-18 17:44 switch between utf-8 and latin-1 ?manu*
@ 2009-07-18 17:59 ` Pascal J. Bourguignon
2009-07-18 19:06 ` switch between utf-8 and latin-1 (ARGH!!) ?manu*
0 siblings, 1 reply; 7+ messages in thread
From: Pascal J. Bourguignon @ 2009-07-18 17:59 UTC (permalink / raw)
To: help-gnu-emacs
?manu* <paolNOini@math.SPAMunifi.it> writes:
> . what method does emacs use to guess the encoding of a text file?
>
> . what is the command to tell emacs that the file in the buffer is
> utf-8 instead of latin-1?
M-x set-buffer-file-coding-system
(Usually bound to C-x RET f)
> . is it possible to insert some text in the file (in comments)
> to tell emacs which encoding to use?
Insert the coding File Variable:
Put: -*- coding:utf-8; -*-
on one of the first two lines,
or put:
Local Variables:
coding: utf-8
End:
in the last 512 bytes of the file.
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: switch between utf-8 and latin-1 (ARGH!!)
2009-07-18 17:59 ` Pascal J. Bourguignon
@ 2009-07-18 19:06 ` ?manu*
2009-07-18 19:39 ` Anselm Helbig
0 siblings, 1 reply; 7+ messages in thread
From: ?manu* @ 2009-07-18 19:06 UTC (permalink / raw)
To: help-gnu-emacs
Thank you so much. I have spent maybe one or two hours to understand
what was happening to my buffers. I tell you because it's a little bit
funny.
I open my buffer with UTF-8 encoding, and i see all the multibyte
characters scrambled. Then I insert the line -*- coding:utf-8 -*- at the
beginning and I save the buffer. Then I exit emacs and reopen the
buffer. Apparently nothing has changed.
What was happening was that after I write that line on the buffer, when
I save the buffer emacs converted the utf-8 escape characters in utf-8
(this seems a wrong behaviour to me!). Looking with hexdump I can see
that the original two bytes characters become four bytes.
The only solution I found was to use another editor to insert that
line!!! This is awkward!
E.
Pascal J. Bourguignon ha scritto:
> ?manu* <paolNOini@math.SPAMunifi.it> writes:
>
>> . what method does emacs use to guess the encoding of a text file?
>>
>> . what is the command to tell emacs that the file in the buffer is
>> utf-8 instead of latin-1?
>
> M-x set-buffer-file-coding-system
> (Usually bound to C-x RET f)
>
>
>> . is it possible to insert some text in the file (in comments)
>> to tell emacs which encoding to use?
>
> Insert the coding File Variable:
>
> Put: -*- coding:utf-8; -*-
> on one of the first two lines,
>
> or put:
>
> Local Variables:
> coding: utf-8
> End:
>
> in the last 512 bytes of the file.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: switch between utf-8 and latin-1 (ARGH!!)
2009-07-18 19:06 ` switch between utf-8 and latin-1 (ARGH!!) ?manu*
@ 2009-07-18 19:39 ` Anselm Helbig
2009-07-18 21:57 ` ?manu*
0 siblings, 1 reply; 7+ messages in thread
From: Anselm Helbig @ 2009-07-18 19:39 UTC (permalink / raw)
To: help-gnu-emacs
At Sat, 18 Jul 2009 21:06:43 +0200,
?manu* <paolNOini@math.SPAMunifi.it> wrote:
>
> Thank you so much. I have spent maybe one or two hours to understand
> what was happening to my buffers. I tell you because it's a little bit
> funny.
>
> I open my buffer with UTF-8 encoding, and i see all the multibyte
> characters scrambled. Then I insert the line -*- coding:utf-8 -*- at the
> beginning and I save the buffer. Then I exit emacs and reopen the
> buffer. Apparently nothing has changed.
>
> What was happening was that after I write that line on the buffer, when
> I save the buffer emacs converted the utf-8 escape characters in utf-8
> (this seems a wrong behaviour to me!). Looking with hexdump I can see
> that the original two bytes characters become four bytes.
>
> The only solution I found was to use another editor to insert that
> line!!! This is awkward!
You don't need another editor to do that. Just try to understand what
emacs is doing here: when you added the line about the coding system
emacs understood that you want the contents of the buffer saved with
this coding system. Emacs can not know that the characters on screen
are not what you want! So you first have to get to the point where
Emacs has the correct notion about the coding system. Pascal already
pointed you to `set-buffer-file-coding-system', another way is to use
`universal-coding-system-argument' (C-x RET c) immediately before
opening a file.
HTH,
Anselm
--
Anselm Helbig
mailto:anselm.helbig+news2009@googlemail.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: switch between utf-8 and latin-1 (ARGH!!)
2009-07-18 19:39 ` Anselm Helbig
@ 2009-07-18 21:57 ` ?manu*
2009-07-18 23:54 ` Pascal J. Bourguignon
0 siblings, 1 reply; 7+ messages in thread
From: ?manu* @ 2009-07-18 21:57 UTC (permalink / raw)
To: help-gnu-emacs
Anselm Helbig ha scritto:
> You don't need another editor to do that. Just try to understand what
> emacs is doing here: when you added the line about the coding system
> emacs understood that you want the contents of the buffer saved with
> this coding system. Emacs can not know that the characters on screen
> are not what you want! So you first have to get to the point where
> Emacs has the correct notion about the coding system. Pascal already
> pointed you to `set-buffer-file-coding-system',
This was not useful because it does not change the meaning of the
caracters in the buffer. It only changes the encoding of the characters
when saving to file.
> another way is to use
> `universal-coding-system-argument' (C-x RET c) immediately before
> opening a file.
...yes this was the right command to use...
thanks,
E.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: switch between utf-8 and latin-1 (ARGH!!)
2009-07-18 21:57 ` ?manu*
@ 2009-07-18 23:54 ` Pascal J. Bourguignon
2009-07-19 6:32 ` ?manu*
0 siblings, 1 reply; 7+ messages in thread
From: Pascal J. Bourguignon @ 2009-07-18 23:54 UTC (permalink / raw)
To: help-gnu-emacs
?manu* <paolNOini@math.SPAMunifi.it> writes:
> Anselm Helbig ha scritto:
>> You don't need another editor to do that. Just try to understand what
>> emacs is doing here: when you added the line about the coding system
>> emacs understood that you want the contents of the buffer saved with
>> this coding system. Emacs can not know that the characters on screen
>> are not what you want! So you first have to get to the point where
>> Emacs has the correct notion about the coding system. Pascal already
>> pointed you to `set-buffer-file-coding-system',
>
> This was not useful because it does not change the meaning of the
> caracters in the buffer. It only changes the encoding of the
> characters when saving to file.
Normally, you would have checked the user manual, and on the page
about set-buffer-file-coding-system, you would have seen the
description of universal-coding-system-argument...
(info "(emacs)Text Coding")
File: emacs, Node: Text Coding
27.11 Specifying a Coding System for File Text
==============================================
...
>> another way is to use
>> `universal-coding-system-argument' (C-x RET c) immediately before
>> opening a file.
>
> ...yes this was the right command to use...
>
> thanks,
> E.
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: switch between utf-8 and latin-1 (ARGH!!)
2009-07-18 23:54 ` Pascal J. Bourguignon
@ 2009-07-19 6:32 ` ?manu*
0 siblings, 0 replies; 7+ messages in thread
From: ?manu* @ 2009-07-19 6:32 UTC (permalink / raw)
To: help-gnu-emacs
Pascal J. Bourguignon ha scritto:
> Normally, you would have checked the user manual,
Yes, you're right. I was scared by the large amount of material. I
checked it now, and found another solution:
M-x find-file-literally
But, anyway, the problem was that I didn't understand that emacs was
re-encoding the file when I changed the file variables. I thought that
the variables were read only while reading the file and not also when
saving it... I cannot find a description of this behaviour in the manual.
E.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-07-19 6:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-18 17:44 switch between utf-8 and latin-1 ?manu*
2009-07-18 17:59 ` Pascal J. Bourguignon
2009-07-18 19:06 ` switch between utf-8 and latin-1 (ARGH!!) ?manu*
2009-07-18 19:39 ` Anselm Helbig
2009-07-18 21:57 ` ?manu*
2009-07-18 23:54 ` Pascal J. Bourguignon
2009-07-19 6:32 ` ?manu*
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).