From: Hung-Te Lin To: vim-multibyte@vim.org Subject: fileencodings: detection when writing out X-Mailer: Mutt on Solaris or FreeBSD, http://www.mutt.org/ X-Location: Taipei, Taiwan [Feature Request/Suggestion] Hello all, The 'fileencodings' option in vim is very important and useful when processing unicode and multibyte files. However it works only when reading file. Scenario: * I want to read all files, and write as 'big5(taiwan)' if I can. We know the fileencodings will be tested in order, so: set encoding=utf-8 set fileencodings=ascii,ucs-bom,utf-8,big5 set fileencoding=big5 * So, when editing a new file, my fileencoding is big5 (correct). When editing a ucs-bom/utf-8/big5 files, their encodings will not changed unless I set fileencoding manually. (that's fine) * But problem happens when I start vim with a file written in pure 7-bit ascii. The fileencoding will be 'ascii' then. While I can still type in multibyte characters (because encoding=utf-8), vim fails when writing out the file because it can't convert multibyte characters to 'ascii' encoding. * Changing the fileencodings=ucs-bom,utf-8,big5? OK, i won't get error when writing out. Because when I opened a pure 7-bit file, fileencoding will be utf-8 (not ucs-bom, of course.) so writing out is ok. But the result is a utf-8 file, not big5. I must manually specify charset to convert it. This is a problem when I was using mail program or editing some files. I may start by typing pure English then after several days I'd like to add some multibyte characters. So, I think if vim can also try encodings when writing out files then things will get better. Maybe a fileencodings-in and a fileencodings-out option. Why 2 options instead of trying fileencodings in both reading and writing? Because the order of reading test is fixed to some limitations, as you must put ucs-bom before utf-8, and utf-8 before most multibyte charsets like big5 and japan. So we'll have fileencodings=latin1,ucs-bom,utf-8,big5,japan if we want to read most files. In that case, maybe we'd like to output big5 but fileencodings will try utf-8 first. That's why we need to seperate the option of reading in and writing out. After having an option to specify my preferrence in writing, I can set something like fileencodings-out=latin1,big5,japan,utf-8 With encoding=utf-8, I can type whatever I need. I may start a English artitle, then after adding some Chinese characters my file will be in Big5 encoding. And if I even type some Korean characters, VIM automatically change the encoding to UTF-8. Isn't this great? Best Regards, -- Hung-Te Lin (Francis S.Lin)