Ben Schmidt wrote:
>> First scenario:
>>
>>     set enc=default
>>     set fenc=latin1
>>     set fencs=ucs-bom,utf-8,latin1
>>     set tenc=latin1
>>
>> vim file            --> Correct (fenc=latin1)
>> vim file8           --> Correct (fenc=utf8)
>> cat file8 | view -  --> Correct (fenc=)
>>
>>
>> Second scenario:
>>
>>     set enc=utf8
>>     set fenc=latin1
>>     set fencs=ucs-bom,utf-8,latin1
>>     set tenc=latin1
>>
>> vim file            --> INCORRECT (fenc=latin1)
>> vim file8           --> Correct   (fenc=utf8)
>> cat file  | view -  --> INCORRECT (fenc=)
>> cat file8 | view -  --> Correct   (fenc=)
> 
> Can you double check the value of fenc for the 'vim file' case? I get 
> 'fenc=utf-8' 
> (and display is incorrect, understandably).
> 
> Anyway, I think you have found a Vim bug here.
> 
> CCing this mail to vim_dev.
> 
> The bug is as follows: When Vim gets to the fencs entry that matches enc, as 
> it 
> doesn't need to convert the file, it simply reads it into the buffer. The bug 
> is 
> that Vim does this whether the file is valid for that encoding or not. 
> Expected 
> behaviour: Vim only loads the file without conversion if the file is valid 
> for the 
> encoding; if not, it should move to the next entry in fencs.
> 
> Note that because of this buggy behaviour, Vim's default value for fencs is 
> non-sensical: it will always succeed when it gets to utf-8 when enc=utf-8 
> without 
> trying default or latin1, even if the file is invalid as utf-8.

On Linux, with GTK2-Gnome2 gvim (Huge) and UTF-8 system locale, "vim file" 
reads the Latin1 file, sets 'fenc' to Latin1 and displays it correctly. No 
bug. ('fencs' is set to: ucs-bom,utf-8,default,latin1 .)

On the same platform, "view - <file" displays the file correctly, with 'fenc' 
empty and 'enc' set to UTF-8. I don't know whether this is a bug (I think not).

> 
> Further note that fixing this may cause difficulties when reading from a 
> stdin 
> which can't be rewound, so once fixed, setting fencs prior to reading stdin 
> may 
> become more important to avoid read failures. Previous posts from me and 
> others 
> have explained how to do that if you are unsure, though it looks like you're 
> pretty savvy. I thought this was worth mentioning as this is how the whole 
> thread 
> started!
> 
> Cheers,
> 
> Ben.

Best regards,
Tony.
-- 
You are at a business lunch when you are suddenly overcome with an
uncontrollable desire to pick your nose.  Since this is definitely a
no-no, you:

(a) Pretend to wave to someone across the room and with one fluid
     motion, bury your forefinger in your nostril right up to the 4th
     joint.

(b) Get everyone drunk and organize a nose picking contest with a prize
     to the one who makes his nose bleed first.

(c) Drop your napkin on the floor and when you bend over to pick it up,
     blow your nose on your sock.


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui