diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 6a888320fb9..ecf44fd06d8 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1445,7 +1445,7 @@ @ cdecl vswprintf_s(ptr long wstr ptr) MSVCRT_vswprintf_s @ cdecl vwprintf(wstr ptr) MSVCRT_vwprintf @ cdecl vwprintf_s(wstr ptr) MSVCRT_vwprintf_s -# stub wcrtomb(ptr long ptr) +@ cdecl wcrtomb(ptr long ptr) MSVCRT_wcrtomb # stub wcrtomb_s(ptr ptr long long ptr) @ cdecl wcscat(wstr wstr) ntdll.wcscat @ cdecl wcscat_s(wstr long wstr) MSVCRT_wcscat_s diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 08628d4bd77..555e63a1e2e 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -1083,7 +1083,25 @@ INT CDECL MSVCRT_wctob( MSVCRT_wint_t wchar ) */ INT CDECL MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch ) { - return WideCharToMultiByte( get_locinfo()->lc_codepage, 0, &ch, 1, dst, 6, NULL, NULL ); + BOOL error; + INT size; + + size = WideCharToMultiByte(get_locinfo()->lc_codepage, 0, &ch, 1, dst, dst ? 6 : 0, NULL, &error); + if(!size || error) { + *MSVCRT__errno() = MSVCRT_EINVAL; + return MSVCRT_EOF; + } + return size; +} + +/********************************************************************* + * wcrtomb (MSVCRT.@) + */ +MSVCRT_size_t CDECL MSVCRT_wcrtomb( char *dst, MSVCRT_wchar_t ch, MSVCRT_mbstate_t *s) +{ + if(s) + *s = 0; + return MSVCRT_wctomb(dst, ch); } /*********************************************************************