Please check my code and result:
void test_MultibyteToWideChar()
{
WCHAR wbuf[10] = {};
int ret = MultiByteToWideChar(1253, MB_ERR_INVALID_CHARS,
"\x98\x99\x9A\x9B\x9C\x9D\xFF", 8,
wbuf, 10);
}
The code aims to convert some codepage-1253(Greek) ANSI bytes to Unicode.
Some input ANSI codepoints(0x98, 0x9a etc) does not have character definition, and I thought MultiByteToWideChar should produce error ERROR_NO_UNICODE_TRANSLATION, or, at least, produce U+FFFD(REPLACEMENT CHARACTER) in output buffer.
However, MultiByteToWideChar silently succeeds, just copy the codepoints(0x98, 0x9a etc) to output WCHAR buffer. I think it is ill behavior.
Any idea on this?
Compile with VS2019 16.11 and run on Win10.1909.
==== Update ====
In my first image, MultibyteToWideChar reported fail by returning 0(=FALSE). I checked again, GetLastError() is 1113, ERROR_NO_UNICODE_TRANSLATION. But I have to tell you, that error is triggered by the final input byte \xFF, not by \x98. We can try to convert a single \x98 and see that MultibyteToWideChar returns success. Sure, in my opinion, it is a fake success.


