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

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2022-03-23 11:02:57 +01:00
parent 8ccb24b151
commit b5561c8bba
2 changed files with 32 additions and 0 deletions

View File

@ -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++)

View File

@ -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];