summaryrefslogtreecommitdiff
path: root/src/mbyte.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-02-13 16:49:58 +0100
committerBram Moolenaar <Bram@vim.org>2013-02-13 16:49:58 +0100
commitffeedec023a47a71fe361c4f0cdbee1649ca8c5f (patch)
treea392df81a34df233e873198bcbf36f9075c2cf00 /src/mbyte.c
parenta3914327f73b3d994af6ecb81dace22fab7d8dc7 (diff)
downloadvim-git-ffeedec023a47a71fe361c4f0cdbee1649ca8c5f.tar.gz
updated for version 7.3.814v7.3.814
Problem: Can't input multibyte characters on Win32 console if 'encoding' is different from current codepage. Solution: Use convert_input_safe() instead of convert_input(). Make string_convert_ext() return an error for incomplete input. (Ken Takata)
Diffstat (limited to 'src/mbyte.c')
-rw-r--r--src/mbyte.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mbyte.c b/src/mbyte.c
index 80f669135..fe12c57d4 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -6256,8 +6256,23 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
if (vcp->vc_cpfrom == 0)
tmp_len = utf8_to_utf16(ptr, len, NULL, NULL);
else
- tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
- ptr, len, 0, 0);
+ {
+ tmp_len = MultiByteToWideChar(vcp->vc_cpfrom,
+ unconvlenp ? MB_ERR_INVALID_CHARS : 0,
+ ptr, len, 0, 0);
+ if (tmp_len == 0
+ && GetLastError() == ERROR_NO_UNICODE_TRANSLATION)
+ {
+ if (lenp != NULL)
+ *lenp = 0;
+ if (unconvlenp != NULL)
+ *unconvlenp = len;
+ retval = alloc(1);
+ if (retval)
+ retval[0] = NUL;
+ return retval;
+ }
+ }
tmp = (short_u *)alloc(sizeof(short_u) * tmp_len);
if (tmp == NULL)
break;