To: vim_dev@googlegroups.com Subject: Patch 8.2.2912 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2912 Problem: MS-Windows: most users expect using Unicode. Solution: Default 'encoding' to utf-8 on MS-Windows. (Ken Takata, closes #3907) Files: runtime/doc/options.txt, src/mbyte.c, src/option.c, src/option.h, src/testdir/test_writefile.vim *** ../vim-8.2.2911/runtime/doc/options.txt 2021-05-15 17:23:22.882858583 +0200 --- runtime/doc/options.txt 2021-05-30 17:56:55.696353269 +0200 *************** *** 2824,2830 **** |setcellwidths()| function to change the behavior. *'encoding'* *'enc'* *E543* ! 'encoding' 'enc' string (default: "latin1" or value from $LANG) global Sets the character encoding used inside Vim. It applies to text in the buffers, registers, Strings in expressions, text stored in the --- 2828,2835 ---- |setcellwidths()| function to change the behavior. *'encoding'* *'enc'* *E543* ! 'encoding' 'enc' string (default for MS-Windows: "utf-8", ! otherwise: value from $LANG or "latin1") global Sets the character encoding used inside Vim. It applies to text in the buffers, registers, Strings in expressions, text stored in the *** ../vim-8.2.2911/src/mbyte.c 2021-04-07 19:00:22.448665381 +0200 --- src/mbyte.c 2021-05-30 17:56:55.700353257 +0200 *************** *** 4456,4462 **** // Use the default encoding as it's found by set_init_1(). r = get_encoding_default(); if (r == NULL) ! r = (char_u *)"latin1"; return vim_strsave(r); } --- 4456,4462 ---- // Use the default encoding as it's found by set_init_1(). r = get_encoding_default(); if (r == NULL) ! r = (char_u *)ENC_DFLT; return vim_strsave(r); } *** ../vim-8.2.2911/src/option.c 2021-05-06 18:46:31.039085745 +0200 --- src/option.c 2021-05-30 18:00:58.323757794 +0200 *************** *** 430,443 **** # endif # endif // enc_locale() will try to find the encoding of the current locale. p = enc_locale(); if (p != NULL) { char_u *save_enc; // Try setting 'encoding' and check if the value is valid. ! // If not, go back to the default "latin1". save_enc = p_enc; p_enc = p; if (STRCMP(p_enc, "gb18030") == 0) --- 430,450 ---- # endif # endif + # ifdef MSWIN + // MS-Windows has builtin support for conversion to and from Unicode, using + // "utf-8" for 'encoding' should work best for most users. + p = vim_strsave((char_u *)ENC_DFLT); + # else // enc_locale() will try to find the encoding of the current locale. + // This works best for properly configured systems, old and new. p = enc_locale(); + # endif if (p != NULL) { char_u *save_enc; // Try setting 'encoding' and check if the value is valid. ! // If not, go back to the default encoding. save_enc = p_enc; p_enc = p; if (STRCMP(p_enc, "gb18030") == 0) *** ../vim-8.2.2911/src/option.h 2021-04-16 19:58:15.915249728 +0200 --- src/option.h 2021-05-30 17:56:55.700353257 +0200 *************** *** 127,133 **** #define ENC_UCSBOM "ucs-bom" // check for BOM at start of file // default value for 'encoding' ! #define ENC_DFLT "latin1" // end-of-line style #define EOL_UNKNOWN -1 // not defined yet --- 127,137 ---- #define ENC_UCSBOM "ucs-bom" // check for BOM at start of file // default value for 'encoding' ! #ifdef MSWIN ! # define ENC_DFLT "utf-8" ! #else ! # define ENC_DFLT "latin1" ! #endif // end-of-line style #define EOL_UNKNOWN -1 // not defined yet *** ../vim-8.2.2911/src/testdir/test_writefile.vim 2021-05-29 14:30:40.192274126 +0200 --- src/testdir/test_writefile.vim 2021-05-30 17:56:55.700353257 +0200 *************** *** 501,507 **** CheckMSWindows let save_encoding = &encoding let save_fileencodings = &fileencodings ! set encoding& fileencodings& let text =<< trim END 1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 2 cp1251 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 --- 501,507 ---- CheckMSWindows let save_encoding = &encoding let save_fileencodings = &fileencodings ! set encoding=latin1 fileencodings& let text =<< trim END 1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01 2 cp1251 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 *** ../vim-8.2.2911/src/version.c 2021-05-30 16:42:53.646691762 +0200 --- src/version.c 2021-05-30 17:58:34.588110573 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2912, /**/ -- TIM: Too late. ARTHUR: What? TIM: There he is! [They all turn, and see a large white RABBIT lollop a few yards out of the cave. Accompanied by terrifying chord and jarring metallic monster noise.] "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///