ntdll: Use the Rtl UTF8 conversion functions.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-12-03 12:25:54 +01:00
parent 27f0426b6f
commit f46fa9c92d
2 changed files with 27 additions and 20 deletions

View File

@ -2834,20 +2834,15 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident
}
else
{
/* let's assume utf-8 for now */
int len = wine_utf8_mbstowcs( 0, buffer, size, NULL, 0 );
DWORD len;
WCHAR *new_buff;
if (len == -1)
{
FIXME( "utf-8 conversion failed\n" );
return STATUS_SXS_CANT_GEN_ACTCTX;
}
if (!(new_buff = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
return STATUS_NO_MEMORY;
wine_utf8_mbstowcs( 0, buffer, size, new_buff, len );
/* let's assume utf-8 for now */
RtlUTF8ToUnicodeN( NULL, 0, &len, buffer, size );
if (!(new_buff = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY;
RtlUTF8ToUnicodeN( new_buff, len, &len, buffer, size );
xmlbuf.ptr = new_buff;
xmlbuf.end = xmlbuf.ptr + len;
xmlbuf.end = xmlbuf.ptr + len / sizeof(WCHAR);
status = parse_manifest_buffer( acl, assembly, ai, &xmlbuf );
RtlFreeHeap( GetProcessHeap(), 0, new_buff );
}

View File

@ -636,13 +636,19 @@ void init_locale( HMODULE module )
*/
int ntdll_umbstowcs( DWORD flags, const char *src, int srclen, WCHAR *dst, int dstlen )
{
#ifdef __APPLE__
/* work around broken Mac OS X filesystem that enforces decomposed Unicode */
flags |= MB_COMPOSITE;
DWORD reslen;
NTSTATUS status;
if (unix_table) return wine_cp_mbstowcs( unix_table, flags, src, srclen, dst, dstlen );
if (!dstlen) dst = NULL;
status = RtlUTF8ToUnicodeN( dst, dstlen * sizeof(WCHAR), &reslen, src, srclen );
if (status && status != STATUS_SOME_NOT_MAPPED) return 0;
reslen /= sizeof(WCHAR);
#ifdef __APPLE__ /* work around broken Mac OS X filesystem that enforces decomposed Unicode */
if (reslen && dst) RtlNormalizeString( NormalizationC, dst, reslen, dst, (int *)&reslen );
#endif
return unix_table ?
wine_cp_mbstowcs( unix_table, flags, src, srclen, dst, dstlen ) :
wine_utf8_mbstowcs( flags, src, srclen, dst, dstlen );
return reslen;
}
@ -652,10 +658,16 @@ int ntdll_umbstowcs( DWORD flags, const char *src, int srclen, WCHAR *dst, int d
int ntdll_wcstoumbs( DWORD flags, const WCHAR *src, int srclen, char *dst, int dstlen,
const char *defchar, int *used )
{
if (unix_table)
return wine_cp_wcstombs( unix_table, flags, src, srclen, dst, dstlen, defchar, used );
DWORD reslen;
NTSTATUS status;
if (unix_table) return wine_cp_wcstombs( unix_table, flags, src, srclen, dst, dstlen, defchar, used );
if (used) *used = 0; /* all chars are valid for UTF-8 */
return wine_utf8_wcstombs( flags, src, srclen, dst, dstlen );
if (!dstlen) dst = NULL;
status = RtlUnicodeToUTF8N( dst, dstlen, &reslen, src, srclen * sizeof(WCHAR) );
if (status && status != STATUS_SOME_NOT_MAPPED) return 0;
return reslen;
}