On 22/03/09 00:30, Andreas Klein wrote:
>
> * Tony Mechelynck wrote:
>>
>>> 0000000: 2626 c2a0 0a3d 3d20 0a3c 3c20 0a&&...== .<< .
>>
>> What is 'encoding' set to? (Also 'fileencoding' for the above file.)
>
> if has("multi_byte")
> set encoding=utf-8
> setglobal fileencoding=utf-8 bomb
> set fileencodings=ucs-bom,utf-8,latin1
> endif
>
> I tried deleting these settings from my .vimrc which unfortunately did not
> solve the problem.
> My terminal is set to handle utf-8 and the screen running in it is also set
> to utf-8.
>
>> C2 A0 is UTF-8 representation of U+00A0 NO-BREAK SPACE. Otherwise 0x20
>> is space and 0x0A is linefeed, both of which are rather "normal" in a
>> text file. Does this ring a bell? I don't see anything in this dump that
>> could be understood as \194.
>
> As I see here 0xC2 corresponds to 194 which is an A with some fancy accent
> but I may be mistaken here.
> \194 is what gcc says when I try to compile a file with these characters in
> it.
>
> Hmm maybe there is a way to work around these problems by automatically
> deleting these characters when a file is saved?
> I just don't know how to search for them in vim.
>
Apparently you're saving your file in UTF-8 'fileencoding' (where
anything above 0x7F is represented on disk by two or more bytes) where
gcc expects Latin1. In UTF-8, 0xC2 0xA0 is one codepoint, not two.
Together, these two bytes represent a no-break space character in UTF-8.
In Latin1, the same character would be just 0xA0.
Try
:setlocal fenc=latin1
before saving that kind of file the first time. Once you have done it,
Vim ought to identify the file as a Latin1 file the next time you edit
it, if at least one character above 0x7F is present in the file. If the
whole file consists only of 7-bit ASCII, it is represented identically
in Latin1 and UTF-8.
If you want to use Latin1 for _all_ new files, change your global
'fileencoding' setting.
If you want to make sure that a given file will always be identified as
Latin1 in the future, make sure that it contains at least one character
above 0x7F (for instance a line of "divide-by" signs used as underline
in a header comment) and save it explicitly with ":setlocal fenc=latin1"
that time.
You may be interested in my custom 'statusline', which, among others,
displays the 'fileencoding' of the file near the right end of the status
line. I'm copying it below (so you may paste it into your vimrc if you
like), it's three lines, the middle one quite long, and see ":help
'statusline'" for explanations:
if has("statusline")
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc\ ==\
\"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}][U+%04B]\ %-12.(%l,%c%V%)\ %P
endif
Best regards,
Tony.
--
SECOND SOLDIER: It could be carried by an African swallow!
FIRST SOLDIER: Oh yes! An African swallow maybe ... but not a European
swallow. that's my point.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---