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 -- b...@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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202105301604.14UG4idA1820944%40masaka.moolenaar.net.

Raspunde prin e-mail lui