Hi, Tony.
What you told was the solution I take. I removed the 'utf-16le' from
'fileencodings' option and now everything is working fine. You were right about
that my utf-16le files doesn't had a BOM start. So, now, when I need to read or
edit this kind of file in GVim I just use:
:e ++enc=utf-16le file.txt
And everything goes well too.
Thanks for your help.
Best regards.
Antonello
>
> On 19/01/09 14:37, Alessandro Antonello wrote:
>> Hi Tony.
>>
>> I tried the peace of script that you send. Every new file in GVim get the
>> utf-8
>> encoding. That was OK in the first moment. But when I opened an old files,
>> that was originally created with latin1 encoding, the output is something
>> like:
>>
>> '??????<B0>?????????<C5>??????????????????????????'
>>
>> So I was unable to edit any file that was initially in latin1. Changing the
>> encoding on the fly doesn't work. So, I made a little change in the script
>> you
>> gave me.
>>
>> if has('multi_byte')
>> if&enc !~? '^u'
>> if&tenc == ""
>> let&tenc =&enc
>> endif
>> set enc=utf-8
>> endif
>> " set fencs=ucs-bom,utf-8,utf-16le,latin1
>> set fencs=ucs-bom,latin1,utf-16le,utf-8
>
> Since these are tried left-to-right, and Latin1 (an 8-bit encoding)
> cannot give a 'fail' status, anything right of it will never be tried.
> This is the same as ":set fencs=ucs-bom,latin1". Unicode files with no
> BOM will be opened as Latin1, so UTF-8 characters higher than U+007F
> will be displayed as sequences of 2 or more bytes of gibberish, or
> UTF-16 characters will be displayed as two characters each, the second
> one often a null (^@). Try removing utf-16le from what I sent in my
> previous post. (UTF-16 with BOM will still be recognized.)
>
>> setg fenc=latin1 bomb
>
> I don't understand why this doesn't cause new files to be created in
> Latin1. How do you create them (by which command)?
>
>> else
>> echohl Error
>> echomsg '+multi_byte not compiled-in, cannot use Unicode'
>> echohl None
>> endif
>>
>> Whit this the new files get the latin1 encoding. I am also able to open files
>> with utf-8 encoding. I hope that I can read also files in utf-16le encoding.
>> Even if they get utf-8 encoding at start and I can change the encoding on the
>> fly. This is enough to me.
>>
>> Thanks for your help.
>
> To open any file whose encoding will not be automatically recognized by
> Vim, use (for instance for utf-16le)
>
> :e ++enc=utf-16le foobar.txt
>
> which bypasses the 'fileencodings' heuristics. It can be used for any
> 'fileencoding' but of course you have to know what to use (or you can
> try several until you see something sensible). See ":help ++opt".
>
> To change the encoding of the file currently being edited, use (for
> instance for Chinese)
>
> :setlocal fenc=GB18030
>
> Use :setlocal, not just :set, to avoid clobbering the 'fileencoding'
> settings of other files being edited at the same time. Here too, any
> encoding value can be used. Changing 'fileencoding' sets 'modified'
> automagically to true so Vim will balk if you try to quit without saving
> (and without an exclamation mark).
>
> Best regards,
> Tony.
> --
> When you are about to do an objective and scientific piece of
> investigation of a topic, it is well to have the answer firmly in hand,
> so that you can proceed forthrightly, without being deflected or
> swayed, directly to the goal.
> -- Amrom Katz
>
> >
>
--
Alessandro Antonello
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---