comparison src/mbyte.c @ 4122:d5b1d6177b37 v7.3.814

updated for version 7.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)
author Bram Moolenaar <bram@vim.org>
date Wed, 13 Feb 2013 16:49:58 +0100
parents 43c15135926f
children ff193256398a
comparison
equal deleted inserted replaced
4121:9d93d458e536 4122:d5b1d6177b37
6254 6254
6255 /* 1. codepage/UTF-8 -> ucs-2. */ 6255 /* 1. codepage/UTF-8 -> ucs-2. */
6256 if (vcp->vc_cpfrom == 0) 6256 if (vcp->vc_cpfrom == 0)
6257 tmp_len = utf8_to_utf16(ptr, len, NULL, NULL); 6257 tmp_len = utf8_to_utf16(ptr, len, NULL, NULL);
6258 else 6258 else
6259 tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0, 6259 {
6260 ptr, len, 0, 0); 6260 tmp_len = MultiByteToWideChar(vcp->vc_cpfrom,
6261 unconvlenp ? MB_ERR_INVALID_CHARS : 0,
6262 ptr, len, 0, 0);
6263 if (tmp_len == 0
6264 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION)
6265 {
6266 if (lenp != NULL)
6267 *lenp = 0;
6268 if (unconvlenp != NULL)
6269 *unconvlenp = len;
6270 retval = alloc(1);
6271 if (retval)
6272 retval[0] = NUL;
6273 return retval;
6274 }
6275 }
6261 tmp = (short_u *)alloc(sizeof(short_u) * tmp_len); 6276 tmp = (short_u *)alloc(sizeof(short_u) * tmp_len);
6262 if (tmp == NULL) 6277 if (tmp == NULL)
6263 break; 6278 break;
6264 if (vcp->vc_cpfrom == 0) 6279 if (vcp->vc_cpfrom == 0)
6265 utf8_to_utf16(ptr, len, tmp, unconvlenp); 6280 utf8_to_utf16(ptr, len, tmp, unconvlenp);