Subject: | Re: vim 6.2 - encodings | |
---|---|---|
From: | Antoine J. Mechelynck (anto...@belgacom.net) | |
Date: | May 28, 2004 11:37:56 am | |
List: | com.googlegroups.vim_use |
ji...@altern.org wrote:
Hi there,
I'm playing around with encodings in gvim62 (on winxp). Based on thescript set_utf8.vim by Antoine athttp://vim.sourceforge.net/scripts/script.php?script_id=789, I'veadded the following lines to my _vimrc :
if &termencoding == ""
let &termencoding = &encoding
endif
if exists("+printencoding") && (&printencoding == "")
let &printencoding = &encoding
endif
set fileencodings-=ucs-bom
set fileencodings-=utf-8
if (&fileencodings == "") && (&encoding != "utf-8")
let &fileencodings = &encoding
endif
set fileencodings^=ucs-bom,utf-8
set encoding=utf-8
setglobal fileencoding=utf-8
setglobal bomb
Here's my problem :
o create a new file (which by default is utf-8 encoded)
o close this fileo reopen the file (fileencoding is recognised as utf-8)
o :set fenc=ucs-bom
o :w
o I got error E213: Cannot convert (add ! to write withoutconversion)
What am I doing wrong ?
Thanks in advance.
Cheers /jerome
1) "ucs-bom" is not a real encoding. it is not valid in 'fileencoding'(singular), but it is valid in 'fileencodings' (plural), to tell (g)vim torecognise all Unicode encodings when a "byte-order-mark" is present at thebeginning. (The byte-order-mark is code point U+FEFF "zero-width no-breakspace", which is represented by a different byte sequence in each of thevarious Unicode encodings, and each of whose representations is illegal inall Unicode encodings other than its own, with the exception that the BOMfor UCS-4le is equivalent to the sequence <FEFF><0000> in UCS-2le, so itmust be "assumed" that a file in UCS-2le will not have a null as its first"real" character.
2) If what you want to do is set a BOM at the head of your UTF-8 file, youshould have nothing to do ("setglobal bomb" takes care of that). To makesure of whether it is there or not, use ":setlocal bomb?" (without thequotes, but with the question mark). Vim should answer either " bomb" or"nobomb".
3) To place or remove a BOM on *any* Unicode file, set or unset 'bomb'(respectively).
See :help 'fileencoding' :help 'fileencodings' :help 'bomb'
HTH,Tony.