Alexandre Julliard (@julliard) commented about dlls/mlang/mlang.c:
default: if (*pcSrcSize == -1) *pcSrcSize = lstrlenA(pSrcStr);
while (MultiByteToWideChar(dwEncoding, MB_ERR_INVALID_CHARS, pSrcStr, *pcSrcSize, 0, 0) == 0)
{
(*pcSrcSize)--;
}
This will truncate at the first invalid char, it would need a test to show that this is the correct behavior.
Also it won't do the right thing for a zero-length string.