summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/options.txt3
-rw-r--r--src/mbyte.c2
-rw-r--r--src/option.c9
-rw-r--r--src/option.h6
-rw-r--r--src/testdir/test_writefile.vim2
-rw-r--r--src/version.c2
6 files changed, 19 insertions, 5 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 4fbc014d3..2f69049fc 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -2828,7 +2828,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|setcellwidths()| function to change the behavior.
*'encoding'* *'enc'* *E543*
-'encoding' 'enc' string (default: "latin1" or value from $LANG)
+'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
diff --git a/src/mbyte.c b/src/mbyte.c
index e3d64ba01..f3fdc32e8 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -4456,7 +4456,7 @@ enc_canonize(char_u *enc)
// Use the default encoding as it's found by set_init_1().
r = get_encoding_default();
if (r == NULL)
- r = (char_u *)"latin1";
+ r = (char_u *)ENC_DFLT;
return vim_strsave(r);
}
diff --git a/src/option.c b/src/option.c
index 7c783757b..6ca424e12 100644
--- a/src/option.c
+++ b/src/option.c
@@ -430,14 +430,21 @@ set_init_1(int clean_arg)
# 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 "latin1".
+ // If not, go back to the default encoding.
save_enc = p_enc;
p_enc = p;
if (STRCMP(p_enc, "gb18030") == 0)
diff --git a/src/option.h b/src/option.h
index 30053cc6c..7be729a85 100644
--- a/src/option.h
+++ b/src/option.h
@@ -127,7 +127,11 @@ typedef enum {
#define ENC_UCSBOM "ucs-bom" // check for BOM at start of file
// default value for 'encoding'
-#define ENC_DFLT "latin1"
+#ifdef MSWIN
+# define ENC_DFLT "utf-8"
+#else
+# define ENC_DFLT "latin1"
+#endif
// end-of-line style
#define EOL_UNKNOWN -1 // not defined yet
diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim
index e94071fd7..9200f2b4b 100644
--- a/src/testdir/test_writefile.vim
+++ b/src/testdir/test_writefile.vim
@@ -501,7 +501,7 @@ func Test_write_file_encoding()
CheckMSWindows
let save_encoding = &encoding
let save_fileencodings = &fileencodings
- set encoding& 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
diff --git a/src/version.c b/src/version.c
index 0a82a96f6..d651bdaf2 100644
--- 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 */
/**/
+ 2912,
+/**/
2911,
/**/
2910,