[[UTF8vim| (Japanese)]] [[OsamuAoki| Wiki links]] = Method to edit non-UTF-8 encoded text files under UTF-8 vim = vim operated under UTF-8 environment can handle any text data of any known languages. But not all text data are stored in UTF-8 encoding. Thus, in order to edit non-UTF-8 encoded text files, you need to convert file contents using {{{iconv}}} before and after the edit. The choice of encoding used for the conversion can be listed with {{{iconv -l}}} command. (The processing of the encoding method name is case insensitive but differentiates hyphen and underscore.) Since it is quite cumbersome to manually convert encoding in shell, I describe easier method to access encoding conversion via vim. As a matter of fact, standard vim under UTF-8 environment is set to {{{fileencodings=ucs-bom,utf-8,default,latin1}}}, each encoding in this list is tried in this order during the read process if it succeeds. At last, automatically {{{latin1}}} is selected but it will not be readable display if chosen encoding is a wrong one. In this case, you can read it correctly by reloading with correct encoding. == Method to edit non-UTF-8 encoded text files from commandline == * latain1 == isoO8859-1 will be auto selected. Western european languages (en, fr, de, it, es, pt, nl) * For others, start editting with {{{vim "+e ++enc=... filename"}}} . * {{{vim "+e ++enc=cp932 filename"}}} Japanese (Windows3.1J, SHIFT_JIS) * {{{vim "+e ++enc=eucjp filename"}}} Japanese (Unix) * {{{vim "+e ++enc=iso-2002-jp filename"}}} Japanese (e-mail) * {{{vim "+e ++enc=latin2 filename"}}} Polish (latin2 == iso08859-2) * {{{vim "+e ++enc=koi8-r filename"}}} Russian * {{{vim "+e ++enc=big5 filename"}}} Chinese (zh_TW, Traditional) * {{{vim "+e ++enc=gb2312 filename"}}} Chinese (zh_CN, Simplified) * {{{vim "+e ++enc=euckr filename"}}} Korean (Unix) * If read with wrong encoding, reload it by pressing {{{[Esc]}}} and {{{:e ++enc=newencoding}}} . * For writing back in the original encoding, press {{{[Esc]}}} and {{{:w}}} as usual and overwrite to the original file. * For writing back in UTF-8, press {{{[Esc]}}} and {{{:w ++enc=utf-8 newfilename.txt}}} and save to the new file. == Method to edit non-UTF-8 encoded text files via GUI == You can add menu to gvim to cope with non-UTF-8 encoding files by adding following script to {{{~/.vimrc}}}. You should customize this to your required encodings. Here, please select {{{Reload with ++enc...}}} for reloading file and {{{Save with ++enc...}}} for save file in a particular encoding. {{{ " " Menu: Access to old encodings and conversion " Translated By: Osamu AOKI " Last Change: 30-Dec-2006. if has('iconv') " Check iconv version let support_jisx0213 = (iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb") ? 1 : 0 " an 10.328.100.100 &File.&Reload\ with\ ++enc\.\.\..&SJISfenc=cp932 :e ++enc=cp932 if !support_jisx0213 an 10.328.100.110 &File.&Reload\ with\ ++enc\.\.\..EUC&JPfenc=euc-jp :e ++enc=euc-jp an 10.328.100.120 &File.&Reload\ with\ ++enc\.\.\..J&ISfenc=iso-2022-jp :e ++enc=iso-2022-jp else an 10.328.100.110 &File.&Reload\ with\ ++enc\.\.\..EUC&JPfenc=euc-jisx0213 :e ++enc=euc-jisx0213 an 10.328.100.120 &File.&Reload\ with\ ++enc\.\.\..J&ISfenc=iso-2022-jp-3 :e ++enc=iso-2022-jp-3 endif an 10.328.100.130 &File.&Reload\ with\ ++enc\.\.\..EUC&KRfenc=euckr :e ++enc=euckr an 10.328.100.140 &File.&Reload\ with\ ++enc\.\.\..&GB2312(zh_CN)fenc=gb2312 :e ++enc=gb an 10.328.100.150 &File.&Reload\ with\ ++enc\.\.\..&BIG5(zh_TW)fenc=big5 :e ++enc=big5 an 10.328.100.200 &File.&Reload\ with\ ++enc\.\.\..-SEPRELOAD1- an 10.328.100.201 &File.&Reload\ with\ ++enc\.\.\..latin&1fenc=latin1 :e ++enc=latin1 an 10.328.100.202 &File.&Reload\ with\ ++enc\.\.\..latin&2fenc=latin2 :e ++enc=latin2 an 10.328.100.203 &File.&Reload\ with\ ++enc\.\.\..latin&3fenc=latin3 :e ++enc=latin3 an 10.328.100.204 &File.&Reload\ with\ ++enc\.\.\..latin&4fenc=latin4 :e ++enc=latin4 an 10.328.100.205 &File.&Reload\ with\ ++enc\.\.\..latin&5fenc=latin5 :e ++enc=latin5 an 10.328.100.206 &File.&Reload\ with\ ++enc\.\.\..latin&6fenc=latin6 :e ++enc=latin6 an 10.328.100.207 &File.&Reload\ with\ ++enc\.\.\..latin&7fenc=latin7 :e ++enc=latin7 an 10.328.100.208 &File.&Reload\ with\ ++enc\.\.\..latin&8fenc=latin8 :e ++enc=latin8 an 10.328.100.209 &File.&Reload\ with\ ++enc\.\.\..latin&9fenc=latin9 :e ++enc=latin9 an 10.328.100.210 &File.&Reload\ with\ ++enc\.\.\..latin1&0fenc=latin10 :e ++enc=latin10 an 10.328.100.800 &File.&Reload\ with\ ++enc\.\.\..-SEPRELOAD2- an 10.328.100.900 &File.&Reload\ with\ ++enc\.\.\..&UTF-8fenc=utf-8 :e ++enc=utf-8 " Save with ++enc as ... an 10.360.120.100 &File.&Save\ with\ ++enc\.\.\..&SJISfenc=cp932 :browse confirm saveas ++enc=cp932 if !support_jisx0213 an 10.360.120.110 &File.&Save\ with\ ++enc\.\.\..EUC&JPfenc=euc-jp :browse confirm saveas ++enc=euc-jp an 10.360.120.120 &File.&Save\ with\ ++enc\.\.\..J&ISfenc=iso-2022-jp :browse confirm saveas ++enc=iso-2022-jp else an 10.360.120.110 &File.&Save\ with\ ++enc\.\.\..EUC&JPfenc=euc-jisx0213 :browse confirm saveas ++enc=euc-jisx0213 an 10.360.120.120 &File.&Save\ with\ ++enc\.\.\..J&ISfenc=iso-2022-jp-3 :browse confirm saveas ++enc=iso-2022-jp-3 endif an 10.360.120.130 &File.&Save\ with\ ++enc\.\.\..EUC&KRfenc=euckr :browse confirm saveas ++enc=euck an 10.360.120.140 &File.&Save\ with\ ++enc\.\.\..&GB(zh_CN)fenc=gb :browse confirm saveas ++enc=gb an 10.360.120.150 &File.&Save\ with\ ++enc\.\.\..&BIG5(zh_TW)fenc=big5 :browse confirm saveas ++enc=big5 an 10.360.120.200 &File.&Save\ with\ ++enc\.\.\..-SEPSAVE1- an 10.360.120.201 &File.&Save\ with\ ++enc\.\.\..latin&1fenc=latin1 :browse confirm saveas ++enc=latin1 an 10.360.120.202 &File.&Save\ with\ ++enc\.\.\..latin&2fenc=latin2 :browse confirm saveas ++enc=latin2 an 10.360.120.203 &File.&Save\ with\ ++enc\.\.\..latin&3fenc=latin3 :browse confirm saveas ++enc=latin3 an 10.360.120.204 &File.&Save\ with\ ++enc\.\.\..latin&4fenc=latin4 :browse confirm saveas ++enc=latin4 an 10.360.120.205 &File.&Save\ with\ ++enc\.\.\..latin&5fenc=latin5 :browse confirm saveas ++enc=latin5 an 10.360.120.206 &File.&Save\ with\ ++enc\.\.\..latin&6fenc=latin6 :browse confirm saveas ++enc=latin6 an 10.360.120.207 &File.&Save\ with\ ++enc\.\.\..latin&7fenc=latin7 :browse confirm saveas ++enc=latin7 an 10.360.120.208 &File.&Save\ with\ ++enc\.\.\..latin&8fenc=latin8 :browse confirm saveas ++enc=latin8 an 10.360.120.209 &File.&Save\ with\ ++enc\.\.\..latin&9fenc=latin9 :browse confirm saveas ++enc=latin9 an 10.360.120.210 &File.&Save\ with\ ++enc\.\.\..latin1&0fenc=latin10 :browse confirm saveas ++enc=latin10 an 10.360.120.800 &File.&Save\ with\ ++enc\.\.\..-SEPSAVE2- an 10.360.120.900 &File.&Save\ with\ ++enc\.\.\..&UTF-8fenc=utf-8 :browse confirm saveas ++enc=utf-8 endif " filler to avoid the line above being recognized as a modeline " filler " filler " filler }}} == Input characters not found in the keyboad == See [[JapaneseEnvironmentE| (English)]] [[JapaneseEnvironment| (Japanese)]] as example.