On Mon, Jun 8, 2009 at 3:35 PM, Bram Moolenaar wrote: > > Yukihiro Nakadaira wrote: > >> When 'encoding' is utf-16 (or ucs-2 or ucs-4) and 'fileencoding' is >> utf-8, Vim converts encoding wrongly. >> >> Steps to reproduce: >> :set enc=utf-16 >> :e ++enc=utf-8 utf8-multi-byte-text.txt >> (At this time, file is properly loaded) >> :w >> Then, Vim breaks the file. >> >> It seems that Vim converts the internal utf-8 text from latin1 to utf-8. >> >> This problem doesn't occur when fenc is not utf-8. > > I'll put it in the todo list. Using utf-16 for 'encoding' is rather > unusual, but we must not destroy the file contents even in rare > situations.
Well, keeping in mind that vim will use utf-8 internally even if you explicitly :set enc=utf-16, maybe the best fix would be to always change &encoding to 'utf-8' whenever doing a :set encoding=SomethingUnicode? It seems like it would fix this bug. This bug, as far as I can tell from a quick glance, is because vim tries to convert from UTF-16 (&enc) to UTF-8 (&fenc) when writing the file, and since the buffer is being internally stored as UTF-8 this is the wrong thing to do. ~Matt --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
