readline.c: fix 8b2e925c

This commit is contained in:
Thomas Bernard
2020-04-13 01:42:45 +02:00
parent 2c9b79a6af
commit 00323b1942
3 changed files with 18 additions and 9 deletions

View File

@@ -709,15 +709,7 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
unicode_text[0] = 0;
}
#elif defined(WIN32)
// use MultiByteToWideChar(CP_UTF8, ...) under WIN32
// Note : For UTF-8, dwFlags must be set to either 0 or
// MB_ERR_INVALID_CHARS.
i = MultiByteToWideChar(CP_UTF8, 0, Key_Text, -1, (LPWSTR)unicode_text, sizeof(unicode_text)/sizeof(word));
if (i == 0)
{
GFX2_Log(GFX2_ERROR, "MultiByteToWideChar(CP_UTF8, \"%s\", ...) failed with error #%u\n", Key_Text, GetLastError());
unicode_text[0] = 0;
}
Unicode_from_utf8(Key_Text, unicode_text, sizeof(unicode_text)/sizeof(word));
#else
int j;
for (i = 0, j = 0; i < (int)sizeof(Key_Text) && j < (int)sizeof(unicode_text) && Key_Text[i] != '\0'; i++)