> 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. 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. Send instant messages to your online friends http://au.messenger.yahoo.com --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
