Saturday, January 22, 2011

Re: cp1252 characters when enc=utf-8, fenc=cp1252

On 23/01/11 9:41 AM, Ben Fritz wrote:
> On Jan 22, 9:43 am, sergio<mail...@sergio.spb.ru> wrote:
>> On 01/21/2011 09:37 PM, Ben Fritz wrote:
>>
>> When fileencoding and encoding are different, vim converts file content from
>> fileencoding to encoding on read and vice versa on write. So you
>> actually work
>> with utf8 characters. If you want to work with cp1251, you need to change
>> encoding
>
> I somehow have the impression that changing encoding while Vim was
> already up and running is a bad idea. I don't really know *what* it
> could mess up. Anyone?

Changing 'fileencoding' isn't a problem. It will cause the file to be
written with a different encoding when the time comes. Changing this
option is the proper way to convert a file between encodings in Vim.

But 'encoding' sets the internal encoding used by Vim for all its
buffers, registers, and basically everywhere else text is stored. And
changing 'encoding' will not convert anything, it will just reinterpret
all the data Vim already has in memory, with quite probably disastrous
results for everything other than basic Latin characters. So you
definitely don't want to change this when Vim is running. If you use
viminfo to save registers between sessions (which you quite probably do
without even realising), you quite probably don't want to change
'encoding' ever.

Ben.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment