diff options
author | Floris van Liere <Floris.van.Liere@gmail.com> | 2015-03-07 14:06:37 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-03-07 17:53:04 -0500 |
commit | 57811dec95dba83fa9ed50e32bdad138dd586720 (patch) | |
tree | aa420b3e7612115e21023cf0c22c8a899413aa53 | |
parent | 85f5115723e22febea98764710d0b5f18e2c9330 (diff) | |
download | rneovim-57811dec95dba83fa9ed50e32bdad138dd586720.tar.gz rneovim-57811dec95dba83fa9ed50e32bdad138dd586720.tar.bz2 rneovim-57811dec95dba83fa9ed50e32bdad138dd586720.zip |
set_init_1: mb_init() on fallback encoding (utf8) #2106
Explanation:
Running `:set encoding=utf-8` _after_ startup correctly initializes
multibyte; but mb_init() was _not_ called during startup if locale
detection (enc_locale()) failed. This wasn't a problem in Vim because
the Vim default encoding (latin1) does not require mb_init(). But Nvim
defaults to utf8, so mb_init() is required.
closes #1271
closes #1672
-rw-r--r-- | src/nvim/option.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 9571398ed1..3d596f81cc 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1989,7 +1989,7 @@ void set_init_1(void) 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 "utf-8". */ save_enc = p_enc; p_enc = p; if (STRCMP(p_enc, "gb18030") == 0) { @@ -2029,8 +2029,13 @@ void set_init_1(void) } else { free(p_enc); + // mb_init() failed; fallback to utf8 and try again. p_enc = save_enc; + mb_init(); } + } else { + // enc_locale() failed; initialize the default (utf8). + mb_init(); } /* Set the default for 'helplang'. */ |