libwine: MB_ERR_INVALID_CHARS makes an error when the undefined byte character is used.

This commit is contained in:
Akihiro Sagawa 2011-04-04 19:01:01 +09:00 committed by Alexandre Julliard
parent 79d7cd76f9
commit 16d5737009
2 changed files with 11 additions and 3 deletions

View File

@ -385,7 +385,6 @@ static void test_undefined_byte_char(void)
ret = MultiByteToWideChar(testset[i].codepage, MB_ERR_INVALID_CHARS,
testset[i].str, -1, NULL, 0);
if (testset[i].is_error) {
todo_wine
ok(ret == 0 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION,
"ret is %d, GetLastError is %u (cp %d)\n",
ret, GetLastError(), testset[i].codepage);

View File

@ -39,6 +39,13 @@ static int get_decomposition( WCHAR src, WCHAR *dst, unsigned int dstlen )
return res;
}
/* check the code whether it is in Unicode Private Use Area (PUA). */
/* MB_ERR_INVALID_CHARS raises an error converting from 1-byte character to PUA. */
static inline int is_private_use_area_char(WCHAR code)
{
return (code >= 0xe000 && code <= 0xf8ff);
}
/* check src string for invalid chars; return non-zero if invalid char found */
static inline int check_invalid_chars_sbcs( const struct sbcs_table *table, int flags,
const unsigned char *src, unsigned int srclen )
@ -49,7 +56,8 @@ static inline int check_invalid_chars_sbcs( const struct sbcs_table *table, int
+ (def_unicode_char & 0xff)];
while (srclen)
{
if (cp2uni[*src] == def_unicode_char && *src != def_char) break;
if ((cp2uni[*src] == def_unicode_char && *src != def_char) ||
is_private_use_area_char(cp2uni[*src])) break;
src++;
srclen--;
}
@ -167,7 +175,8 @@ static inline int check_invalid_chars_dbcs( const struct dbcs_table *table,
src++;
srclen--;
}
else if (cp2uni[*src] == def_unicode_char && *src != def_char) break;
else if ((cp2uni[*src] == def_unicode_char && *src != def_char) ||
is_private_use_area_char(cp2uni[*src])) break;
src++;
srclen--;
}