diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-08-03 17:37:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-08-03 17:37:48 +0200 |
commit | 01efafad12102df0f1e341d6cadcb7be971591c1 (patch) | |
tree | 9167018f081c6d2691b85cbd509d4876e6f3864c | |
parent | 3c3a80dc59ccc0e0aabb9c8bd58ea84a801dbfc1 (diff) | |
download | vim-git-01efafad12102df0f1e341d6cadcb7be971591c1.tar.gz |
patch 8.0.0850: MS-Windows: error message while starting up may be brokenv8.0.0850
Problem: MS-Windows: Depending on the console encoding, an error message
that is given during startup may be broken.
Solution: Convert the message to the console codepage. (Yasuhiro Matsumoto,
closes #1927)
-rw-r--r-- | src/message.c | 24 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/message.c b/src/message.c index 4273f236a..9a4a32f3e 100644 --- a/src/message.c +++ b/src/message.c @@ -2628,10 +2628,29 @@ msg_puts_printf(char_u *str, int maxlen) char_u *s = str; char_u buf[4]; char_u *p; - #ifdef WIN3264 +# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN) + char_u *ccp = NULL; + +# endif if (!(silent_mode && p_verbose == 0)) mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */ + +# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN) + if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage) + { + int len; + WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &len); + + if (widestr != NULL) + { + WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, len, + (LPSTR *)&ccp, &len, 0, 0); + vim_free(widestr); + s = str = ccp; + } + } +# endif #endif while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL) { @@ -2675,6 +2694,9 @@ msg_puts_printf(char_u *str, int maxlen) msg_didout = TRUE; /* assume that line is not empty */ #ifdef WIN3264 +# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN) + vim_free(ccp); +# endif if (!(silent_mode && p_verbose == 0)) mch_settmode(TMODE_RAW); #endif diff --git a/src/version.c b/src/version.c index 8a029184c..c5c39fea2 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 850, +/**/ 849, /**/ 848, |