Commit 63ad05bc authored by Alexandre Julliard's avatar Alexandre Julliard

win32u: Use character sizes in the codepage conversion functions.

For consistency with ntdll. Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 65ff9cac
......@@ -3243,7 +3243,7 @@ DWORD win32u_wctomb( CPTABLEINFO *info, char *dst, DWORD dstlen, const WCHAR *sr
if (!info && !(info = get_cptable( get_acp() ))) return 0;
RtlUnicodeToCustomCPN( info, dst, dstlen, &ret, src, srclen );
RtlUnicodeToCustomCPN( info, dst, dstlen, &ret, src, srclen * sizeof(WCHAR) );
return ret;
}
......@@ -3253,8 +3253,8 @@ DWORD win32u_mbtowc( CPTABLEINFO *info, WCHAR *dst, DWORD dstlen, const char *sr
if (!info && !(info = get_cptable( get_acp() ))) return 0;
RtlCustomCPToUnicodeN( info, dst, dstlen, &ret, src, srclen );
return ret;
RtlCustomCPToUnicodeN( info, dst, dstlen * sizeof(WCHAR), &ret, src, srclen );
return ret / sizeof(WCHAR);
}
static BOOL wc_to_index( UINT cp, WCHAR wc, unsigned char *dst, BOOL allow_default )
......
......@@ -782,9 +782,8 @@ static WCHAR *copy_name_table_string( const FT_SfntName *name )
case TT_PLATFORM_MACINTOSH:
if (!(cp = get_mac_code_page( name ))) return NULL;
ret = malloc( (name->string_len + 1) * sizeof(WCHAR) );
i = win32u_mbtowc( cp, ret, name->string_len * sizeof(WCHAR),
(char *)name->string, name->string_len );
ret[i / sizeof(WCHAR)] = 0;
i = win32u_mbtowc( cp, ret, name->string_len, (char *)name->string, name->string_len );
ret[i] = 0;
return ret;
}
return NULL;
......@@ -1142,8 +1141,7 @@ static WCHAR *decode_opentype_name( struct opentype_name *name )
{
CPTABLEINFO *cptable = get_cptable( name->codepage );
if (!cptable) return NULL;
len = win32u_mbtowc( cptable, buffer, sizeof(buffer), name->bytes, name->length );
len /= sizeof(WCHAR);
len = win32u_mbtowc( cptable, buffer, ARRAY_SIZE(buffer), name->bytes, name->length );
}
buffer[ARRAY_SIZE(buffer) - 1] = 0;
......@@ -2526,7 +2524,7 @@ static BOOL freetype_get_glyph_index( struct gdi_font *font, UINT *glyph, BOOL u
DWORD len;
char ch;
len = win32u_wctomb( NULL, &ch, 1, &wc, sizeof(wc) );
len = win32u_wctomb( NULL, &ch, 1, &wc, 1 );
if (len) *glyph = get_glyph_index_symbol( font, (unsigned char)ch );
}
return TRUE;
......
......@@ -593,7 +593,7 @@ static inline WCHAR *towstr( const char *str )
{
DWORD len = strlen( str ) + 1;
WCHAR *ret = malloc( len * sizeof(WCHAR) );
if (ret) win32u_mbtowc( NULL, ret, len * sizeof(WCHAR), str, len );
if (ret) win32u_mbtowc( NULL, ret, len, str, len );
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment