Alexandre Julliard : ntdll: Use the Rtl UTF8 conversion functions.
Alexandre Julliard
julliard at winehq.org
Wed Dec 4 16:13:04 CST 2019
Module: wine
Branch: master
Commit: f46fa9c92d08c6e656bc22b94e09aa9dbe7d3be9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f46fa9c92d08c6e656bc22b94e09aa9dbe7d3be9
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Dec 3 12:25:54 2019 +0100
ntdll: Use the Rtl UTF8 conversion functions.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/actctx.c | 17 ++++++-----------
dlls/ntdll/locale.c | 30 +++++++++++++++++++++---------
2 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c
index d5f2f70273..9e7782c1ee 100644
--- a/dlls/ntdll/actctx.c
+++ b/dlls/ntdll/actctx.c
@@ -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 );
}
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index d7a6401560..f5faada578 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -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;
}
More information about the wine-cvs
mailing list