# HG changeset patch # User Bram Moolenaar # Date 1622479503 -7200 # Node ID a4cb7499fa119c1e5239f099cb7eee350c5d6e46 # Parent 1018030b38b2ee257c4b940b69279e3ab399c22f patch 8.2.2915: MS-Windows: when using "default" for encoding utf-8 is used Commit: https://github.com/vim/vim/commit/ef8706fb84cfe8bd58b1b26b0742e42caf09655b Author: K.Takata Date: Mon May 31 18:40:49 2021 +0200 patch 8.2.2915: MS-Windows: when using "default" for encoding utf-8 is used Problem: MS-Windows: when using "default" for encoding utf-8 is used. Solution: Use the system encoding. (Ken Takata, closes https://github.com/vim/vim/issues/8300) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3116,9 +3116,10 @@ A jump table for the options with a shor because Vim cannot detect an error, thus the encoding is always accepted. The special value "default" can be used for the encoding from the - environment. This is the default value for 'encoding'. It is useful - when 'encoding' is set to "utf-8" and your environment uses a - non-latin1 encoding, such as Russian. + environment. On MS-Windows this is the system encoding. Otherwise + this is the default value for 'encoding'. It is useful when + 'encoding' is set to "utf-8" and your environment uses a non-latin1 + encoding, such as Russian. When 'encoding' is "utf-8" and a file contains an illegal byte sequence it won't be recognized as UTF-8. You can use the |8g8| command to find the illegal byte sequence. diff --git a/src/mbyte.c b/src/mbyte.c --- a/src/mbyte.c +++ b/src/mbyte.c @@ -4453,8 +4453,13 @@ enc_canonize(char_u *enc) if (STRCMP(enc, "default") == 0) { +#ifdef MSWIN + // Use the system encoding, the default is always utf-8. + r = enc_locale(); +#else // Use the default encoding as it's found by set_init_1(). r = get_encoding_default(); +#endif if (r == NULL) r = (char_u *)ENC_DFLT; return vim_strsave(r); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2915, +/**/ 2914, /**/ 2913,