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.
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);