Sunday, January 23, 2011

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

On 24/01/11 3:54 AM, Benjamin Fritz wrote:
> On Sat, Jan 22, 2011 at 5:37 PM, Ben Schmidt
> <mail_ben_schmidt@yahoo.com.au> wrote:
>> On 23/01/11 9:41 AM, Ben Fritz wrote:
>>>
>>> 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.
>
> Right, I do this now.
>
>> 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.
>
> Ah, so if I change 'enc' while Vim is running, and then go to paste
> text yanked from a utf-8 buffer, but now my encoding is cp1252, it
> would paste two garbage bytes instead of a single en dash (for
> example). I assume mappings, etc. might be messed up as well?

Correct.

Smiles,

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