2 #include <msvcrt/stdlib.h>
3 #include <msvcrt/ctype.h>
8 int mbtowc(wchar_t *dst
, const char *str
, size_t n
)
10 // printf("\t\t\tmbtowc(%p, %p, %d) called.\n", dst, str, n);
24 int mbtowc(wchar_t *dst
, const char *str
, size_t n
)
28 if (!MultiByteToWideChar(CP_ACP
, 0, str
, n
, dst
, (dst
== NULL
) ? 0 : 1)) {
29 DWORD err
= GetLastError();
31 case ERROR_INSUFFICIENT_BUFFER
:
33 case ERROR_INVALID_FLAGS
:
35 case ERROR_INVALID_PARAMETER
:
37 case ERROR_NO_UNICODE_TRANSLATION
:
44 /* return the number of bytes from src that have been used */
47 if (n
>= 2 && isleadbyte(*str
) && str
[1])