2 #include <msvcrt/stdlib.h>
3 #include <msvcrt/ctype.h>
11 int mbtowc(wchar_t *dst, const char *str, size_t n)
13 // printf("\t\t\tmbtowc(%p, %p, %d) called.\n", dst, str, n);
27 int mbtowc(wchar_t *dst, const char *str, size_t n)
31 if (!MultiByteToWideChar(CP_ACP, 0, str, n, dst, (dst == NULL) ? 0 : 1)) {
32 DWORD err = GetLastError();
34 case ERROR_INSUFFICIENT_BUFFER:
36 case ERROR_INVALID_FLAGS:
38 case ERROR_INVALID_PARAMETER:
40 case ERROR_NO_UNICODE_TRANSLATION:
47 /* return the number of bytes from src that have been used */
50 if (n >= 2 && isleadbyte(*str) && str[1])