Saturday, January 22, 2011

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

On 22/01/11 5:37 AM, Ben Fritz wrote:
> I have a file encoded as cp1252. I have my encoding set to utf-8, and
> my fileencodings set up such that when this file is read in, it gets
> an fenc of cp1252 and is read in properly.
>
> In this file is an en dash, encoded as byte value 150. The Unicode
> value for this is 8211.
>
> I would expect that pressing ga on this character would show 150, but
> instead it shows 8211. Why?
>
> Furthermore, I would expect to be able to enter this character by
> typing<C-V>150 in insert mode, or by typing<C-V>u2013. However, only
> the latter works.
>
> Finally, I would expect to be able to search for this character using
> either /[\d150] or /[\u2013], but again only the latter works.
>
> Is Vim supposed to act this way? Why?

I think so. :help 'fileencoding' describes conversion as taking place
when files are written and read, implying that when a file is actually
being edited, it is in 'encoding', and commands within Vim working on
the file would be expected to use 'encoding' also. 'fileencoding'
doesn't affect the encoding with which the file is edited and
manipulated in Vim; it just changes the way it is read and written.

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: