Bram Moolenaar wrote: > > Matt Wozniski wrote: > > > > > 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. > > The main reason one would set 'encoding' to utf-16 is when this should > be the default file format. On MS-Windows some files are utf-16, if you > are editing a whole bunch of them this could be useful (even though > using utf-8 should work).
Well, that's another thing that has never worked, then. When 'enc' is 'utf-16' and 'fenc' is unset, files are written out in utf-8, not utf-16. Simple testcase: vim -u NONE -N --cmd 'set enc=utf-16 fenc= | exe "normal! i\<C-k>`e" | w !iconv -f utf-16' -c 'q!' iconv: incomplete character or shift sequence at end of buffer shell returned 1 Change the '-f utf-16' to '-f utf-8' and iconv confirms that it's being passed valid utf-8. Is the desired behavior even well defined? The docs seem to contradict; :help 'encoding' says: When "unicode", "ucs-2" or "ucs-4" is used, Vim internally uses utf-8. but :help 'fileencoding' says: When 'fileencoding' is empty, the same value as 'encoding' will be used (no conversion when reading or writing a file). In this case, 'fileencoding' is empty, but conversion *is* supposed to occur when writing the file (from the internal utf-8 buffer to the 'encoding' utf-16). > I don't think finding one bug is a good reason to drop support for this. > It's probably easy to fix. ~Matt --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
