Sunday, May 22, 2011

Re: what's a "conversion error" and how do I correct it?

On May 22, 6:00 am, Christian Brabandt <cbli...@256bit.org> wrote:
> Hi eNG1Ne!
>
> On So, 22 Mai 2011, eNG1Ne wrote:
>
> > Working on a Linux box (Ubuntu 10.4), I've successfully copy/pasted a
> > block of text from a Planmaker spreadsheet into a vim file. The text
> > includes U+2012 dashes, which are correctly displayed in vim … but
> > when I try to save the vim file, I get the message "conversion error".
>
> I guess, your fileencodings setting (notice the plural) does not include
> utf-8, so Vim does not try to save it with that encoding. It probably
> either tries to save it using plain old ASCII encoding or something like
> latin1, which does not include this char and therefore conversion fails.
>
> You should fix your 'fencs' setting to something like
> ucs-bom,utf-8,default,latin1

The 'fileencodings' option is what Vim uses to detect file encoding
when *reading* a file. When writing, Vim uses the current setting of
'fileencoding' (*without* the 's' at the end) as the encoding in which
to write the file.

If the file did not originally have Unicode characters in it, quite
possibly it was not detected as Unicode, so 'fileencoding' will be set
to something else (from the 'filencodings' option) or it will be
empty. If 'fileencoding' is empty, the value of 'encoding' is used
instead.

At least, this is how I understand it. Is there some situation I'm
missing in which 'filencodings' (with the 's') is relevant to a write
operation?

> or you can force Vim to save it in utf-8
> encoding, by issuing :w ++enc=utf8 filename.

This is true, but you can also do a

:setlocal fileencoding=utf-8

before saving.

> (It might be, that this
> needs the +multi_byte feature, which is only enabled, when compiling at
> least a big version of Vim).
>

Yes, I'm pretty sure it does require +multi_byte.

See our current featured tip on working with Unicode in Vim:

http://vim.wikia.com/wiki/Working_with_Unicode

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