Problem: MS-Windows: most users expect using Unicode.
Solution: Default 'encoding' to utf-8 on MS-Windows. (Ken Takata,
closes #3907)
|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
// 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);
}
# 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)
#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
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2912,
/**/
2911,
/**/