forked from Mirrors/wine-wine
msvcrt: Added mbrtowc implementation.
parent
00658a4a63
commit
4b67531bf7
|
@ -1995,7 +1995,7 @@ int CDECL MSVCRT_mbtowc_l(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n,
|
|||
/* return the number of bytes from src that have been used */
|
||||
if(!*str)
|
||||
return 0;
|
||||
if(n >= 2 && MSVCRT__isleadbyte_l(*str, locale) && str[1])
|
||||
if(n >= 2 && MSVCRT__isleadbyte_l((unsigned char)*str, locale) && str[1])
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
@ -2008,6 +2008,53 @@ int CDECL MSVCRT_mbtowc(MSVCRT_wchar_t *dst, const char* str, MSVCRT_size_t n)
|
|||
return MSVCRT_mbtowc_l(dst, str, n, NULL);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* mbrtowc(MSVCRT.@)
|
||||
*/
|
||||
MSVCRT_size_t CDECL MSVCRT_mbrtowc(MSVCRT_wchar_t *dst, const char *str,
|
||||
MSVCRT_size_t n, MSVCRT_mbstate_t *state)
|
||||
{
|
||||
MSVCRT_pthreadlocinfo locinfo = get_locinfo();
|
||||
MSVCRT_mbstate_t s = (state ? *state : 0);
|
||||
char tmpstr[2];
|
||||
int len = 0;
|
||||
|
||||
if(dst)
|
||||
*dst = 0;
|
||||
|
||||
if(!n || !str || !*str)
|
||||
return 0;
|
||||
|
||||
if(locinfo->mb_cur_max == 1) {
|
||||
tmpstr[len++] = *str;
|
||||
}else if(!s && MSVCRT_isleadbyte((unsigned char)*str)) {
|
||||
if(n == 1) {
|
||||
s = (unsigned char)*str;
|
||||
len = -2;
|
||||
}else {
|
||||
tmpstr[0] = str[0];
|
||||
tmpstr[1] = str[1];
|
||||
len = 2;
|
||||
}
|
||||
}else if(!s) {
|
||||
tmpstr[len++] = *str;
|
||||
}else {
|
||||
tmpstr[0] = s;
|
||||
tmpstr[1] = *str;
|
||||
len = 2;
|
||||
s = 0;
|
||||
}
|
||||
|
||||
if(len > 0) {
|
||||
if(!MultiByteToWideChar(locinfo->lc_codepage, 0, tmpstr, len, dst, dst ? 1 : 0))
|
||||
len = -1;
|
||||
}
|
||||
|
||||
if(state)
|
||||
*state = s;
|
||||
return len;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _mbstowcs_l(MSVCRT.@)
|
||||
*/
|
||||
|
|
|
@ -1329,7 +1329,7 @@
|
|||
@ cdecl malloc(long) MSVCRT_malloc
|
||||
@ cdecl mblen(ptr long) MSVCRT_mblen
|
||||
@ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen
|
||||
# stub mbrtowc(ptr str long ptr)
|
||||
@ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc
|
||||
# stub mbsdup_dbg(wstr long ptr long)
|
||||
# stub mbsrtowcs(ptr ptr long ptr)
|
||||
# stub mbsrtowcs_s(ptr ptr long ptr long ptr)
|
||||
|
|
Loading…
Reference in New Issue