Alexandre Julliard : ntdll: Support UTF-8 codepage in RtlInitCodePageTable().

Alexandre Julliard julliard at winehq.org
Wed Mar 23 17:03:54 CDT 2022


Module: wine
Branch: master
Commit: b5561c8bba9a613c53ae4669c4adb7450e5f458d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b5561c8bba9a613c53ae4669c4adb7450e5f458d

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Mar 23 11:02:57 2022 +0100

ntdll: Support UTF-8 codepage in RtlInitCodePageTable().

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/locale.c | 25 +++++++++++++++++++++++++
 dlls/ntdll/locale.c          |  7 +++++++
 2 files changed, 32 insertions(+)

diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index c910c348d45..2bc368c8bc1 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -4212,6 +4212,31 @@ static void test_GetCPInfo(void)
         ret = UnmapViewOfFile( ptr );
         ok( ret, "UnmapViewOfFile failed err %lu\n", GetLastError() );
 
+        status = pNtGetNlsSectionPtr( 11, 65001, NULL, &ptr, &size );
+        ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "failed %lx\n", status );
+         if (pRtlInitCodePageTable)
+         {
+             static USHORT utf8[20] = { 0, CP_UTF8 };
+
+             memset( &table, 0xcc, sizeof(table) );
+             pRtlInitCodePageTable( utf8, &table );
+             ok( table.CodePage == CP_UTF8, "wrong codepage %u\n", table.CodePage );
+             if (table.MaximumCharacterSize)
+             {
+                 ok( table.MaximumCharacterSize == 4, "wrong char size %u\n", table.MaximumCharacterSize );
+                 ok( table.DefaultChar == '?', "wrong default char %x\n", table.DefaultChar );
+                 ok( table.UniDefaultChar == 0xfffd, "wrong default char %x\n", table.UniDefaultChar );
+                 ok( table.TransDefaultChar == '?', "wrong default char %x\n", table.TransDefaultChar );
+                 ok( table.TransUniDefaultChar == '?', "wrong default char %x\n", table.TransUniDefaultChar );
+                 ok( !table.DBCSCodePage, "wrong dbcs %u\n", table.DBCSCodePage );
+                 ok( !table.MultiByteTable, "wrong mbtable %p\n", table.MultiByteTable );
+                 ok( !table.WideCharTable, "wrong wctable %p\n", table.WideCharTable );
+                 ok( !table.DBCSRanges, "wrong ranges %p\n", table.DBCSRanges );
+                 ok( !table.DBCSOffsets, "wrong offsets %p\n", table.DBCSOffsets );
+             }
+             else win_skip( "utf-8 codepage not supported\n" );
+         }
+
         /* normalization tables */
 
         for (i = 0; i < 100; i++)
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index b4a14c0d68f..74c395cbd85 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -745,6 +745,13 @@ void WINAPI RtlInitCodePageTable( USHORT *ptr, CPTABLEINFO *info )
 {
     USHORT hdr_size = ptr[0];
 
+    if (ptr[1] == CP_UTF8)
+    {
+        static const CPTABLEINFO utf8_cpinfo = { CP_UTF8, 4, '?', 0xfffd, '?', '?' };
+        *info = utf8_cpinfo;
+        return;
+    }
+
     info->CodePage             = ptr[1];
     info->MaximumCharacterSize = ptr[2];
     info->DefaultChar          = ptr[3];




More information about the wine-cvs mailing list