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

@@ -311,6 +311,22 @@ char * Unicode_to_utf8(const word * str, size_t * utf8len)
return utf8;
}
}
/**
* UTF8 to Unicode (16bits per character).
* use MultiByteToWideChar(CP_UTF8, ...) under WIN32.
* Note : For UTF-8, dwFlags must be set to either 0 or MB_ERR_INVALID_CHARS.
*/
void Unicode_from_utf8(const char * utf8, word * unicode, size_t unicodelen)
{
int r = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, (LPWSTR)unicode, unicodelen);
if (r == 0)
{
GFX2_Log(GFX2_ERROR, "MultiByteToWideChar(CP_UTF8, \"%s\", ...) failed with error #%u\n", utf8, GetLastError());
unicode[0] = 0;
}
}
#endif
/**