GetCPInfo(Ex) should work on CP_UTF7/CP_UTF8 pseudo code pages
Dmitry Timoshkov
dmitry at baikal.ru
Mon Aug 23 02:29:06 CDT 2004
Hello,
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
GetCPInfo(Ex) should work on CP_UTF7/CP_UTF8 pseudo code pages,
as IsValidCodePage does.
--- cvs/hq/wine/dlls/kernel/locale.c 2004-08-01 16:39:42.000000000 +0900
+++ wine/dlls/kernel/locale.c 2004-08-23 16:18:22.000000000 +0900
@@ -1305,6 +1305,17 @@ BOOL WINAPI GetCPInfo( UINT codepage, LP
if (!table)
{
+ switch(codepage)
+ {
+ case CP_UTF7:
+ case CP_UTF8:
+ cpinfo->DefaultChar[0] = 0x3f;
+ cpinfo->DefaultChar[1] = 0;
+ cpinfo->LeadByte[0] = cpinfo->LeadByte[1] = 0;
+ cpinfo->MaxCharSize = (codepage == CP_UTF7) ? 5 : 4;
+ return TRUE;
+ }
+
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
@@ -1342,14 +1353,14 @@ BOOL WINAPI GetCPInfo( UINT codepage, LP
*/
BOOL WINAPI GetCPInfoExA( UINT codepage, DWORD dwFlags, LPCPINFOEXA cpinfo )
{
- const union cptable *table = get_codepage_table( codepage );
+ CPINFOEXW cpinfoW;
- if (!GetCPInfo( codepage, (LPCPINFO)cpinfo ))
+ if (!GetCPInfoExW( codepage, dwFlags, &cpinfoW ))
return FALSE;
- cpinfo->CodePage = table->info.codepage;
- cpinfo->UnicodeDefaultChar = table->info.def_unicode_char;
- strcpy(cpinfo->CodePageName, table->info.name);
+ /* the layout is the same except for CodePageName */
+ memcpy(cpinfo, &cpinfoW, sizeof(CPINFOEXA));
+ WideCharToMultiByte(CP_ACP, 0, cpinfoW.CodePageName, -1, cpinfo->CodePageName, sizeof(cpinfo->CodePageName), NULL, NULL);
return TRUE;
}
@@ -1360,15 +1371,42 @@ BOOL WINAPI GetCPInfoExA( UINT codepage,
*/
BOOL WINAPI GetCPInfoExW( UINT codepage, DWORD dwFlags, LPCPINFOEXW cpinfo )
{
- const union cptable *table = get_codepage_table( codepage );
-
if (!GetCPInfo( codepage, (LPCPINFO)cpinfo ))
return FALSE;
- cpinfo->CodePage = table->info.codepage;
- cpinfo->UnicodeDefaultChar = table->info.def_unicode_char;
- MultiByteToWideChar( CP_ACP, 0, table->info.name, -1, cpinfo->CodePageName,
- sizeof(cpinfo->CodePageName)/sizeof(WCHAR));
+ switch(codepage)
+ {
+ case CP_UTF7:
+ {
+ static const WCHAR utf7[] = {'U','n','i','c','o','d','e',' ','(','U','T','F','-','7',')',0};
+
+ cpinfo->CodePage = CP_UTF7;
+ cpinfo->UnicodeDefaultChar = 0x3f;
+ strcpyW(cpinfo->CodePageName, utf7);
+ break;
+ }
+
+ case CP_UTF8:
+ {
+ static const WCHAR utf8[] = {'U','n','i','c','o','d','e',' ','(','U','T','F','-','8',')',0};
+
+ cpinfo->CodePage = CP_UTF8;
+ cpinfo->UnicodeDefaultChar = 0x3f;
+ strcpyW(cpinfo->CodePageName, utf8);
+ break;
+ }
+
+ default:
+ {
+ const union cptable *table = get_codepage_table( codepage );
+
+ cpinfo->CodePage = table->info.codepage;
+ cpinfo->UnicodeDefaultChar = table->info.def_unicode_char;
+ MultiByteToWideChar( CP_ACP, 0, table->info.name, -1, cpinfo->CodePageName,
+ sizeof(cpinfo->CodePageName)/sizeof(WCHAR));
+ break;
+ }
+ }
return TRUE;
}
More information about the wine-patches
mailing list