Thursday, November 29, 2012

Re: Automatically change encoding when opening file

On Thursday, November 29, 2012 2:41:16 PM UTC-6, vtadipatri wrote:
>
> I'm not really that familiar with the different encoding types (UTF-8,
>
> UTF-16, etc), but when I came across a strange <feff> character which
>
> I think is related to what you're describing.
>
> I open up two files in gedit and they seem to contain the same exact
>
> line. But in vim, there's a strange character at the beginning
>
> "<feff>". It's not a string, because if I go to the beginning of the
>
> line and hit 'x', it deletes the entire <feff>, indicating it's some
>
> sort of special hidden character.
>
> What is this strange character? In Vi's hex mode (%!xxd), I can see
>
> there is a sequence of bits "efbbbf", and the rest of the file seems
>
> to somehow be offset
>

This strange character is the byte-order-mark ( http://en.wikipedia.org/wiki/Byte_order_mark ). The exact byte sequence you see indicates the file is in utf-8. Vim probably did not detect the file as utf-8.

Check that:
1. your Vim is compiled with multibyte support
2. your 'encoding' option is set AT THE VERY BEGINNING OF YOUR .VIMRC to utf-8
3. your 'fileencodings' option contains ucs-bom or utf-8 or both, before any 8-bit encodings.

If these are all the case your Vim should automatically detect the utf-8 fileencoding and the presence of a BOM, and set 'fenc' and 'bomb' appropriately.

See the http://vim.wikia.com/wiki/Working_with_Unicode linked by Tony.

--
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: