Author: dchapyshev
Date: Sun Nov 16 06:15:55 2008
New Revision: 37387
URL:
http://svn.reactos.org/svn/reactos?rev=37387&view=rev
Log:
- Implement GetCPInfo. Now this function passes all Wine tests
Modified:
trunk/reactos/dll/win32/kernel32/misc/lang.c
Modified: trunk/reactos/dll/win32/kernel32/misc/lang.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/la…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/lang.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/lang.c [iso-8859-1] Sun Nov 16 06:15:55 2008
@@ -1238,29 +1238,54 @@
/*
- * @unimplemented
+ * @implemented
*/
BOOL
STDCALL
-GetCPInfo (
- UINT CodePage,
- LPCPINFO CodePageInfo
- )
-{
- unsigned i;
-
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-
- CodePageInfo->MaxCharSize = 1;
- CodePageInfo->DefaultChar[0] = '?';
- for (i = 1; i < MAX_DEFAULTCHAR; i++)
- {
- CodePageInfo->DefaultChar[i] = 0;
- }
- for (i = 0; i < MAX_LEADBYTES; i++)
- {
- CodePageInfo->LeadByte[i] = 0;
- }
+GetCPInfo(UINT CodePage,
+ LPCPINFO CodePageInfo)
+{
+ PCODEPAGE_ENTRY CodePageEntry;
+
+ if (!CodePageInfo)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ CodePageEntry = IntGetCodePageEntry(CodePage);
+ if (CodePageEntry == NULL)
+ {
+ switch(CodePage)
+ {
+ case CP_UTF7:
+ case CP_UTF8:
+ CodePageInfo->DefaultChar[0] = 0x3f;
+ CodePageInfo->DefaultChar[1] = 0;
+ CodePageInfo->LeadByte[0] = CodePageInfo->LeadByte[1] = 0;
+ CodePageInfo->MaxCharSize = (CodePage == CP_UTF7) ? 5 : 4;
+ return TRUE;
+ }
+
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+
+ if (CodePageEntry->CodePageTable.DefaultChar & 0xff00)
+ {
+ CodePageInfo->DefaultChar[0] = (CodePageEntry->CodePageTable.DefaultChar
& 0xff00) >> 8;
+ CodePageInfo->DefaultChar[1] = CodePageEntry->CodePageTable.DefaultChar
& 0x00ff;
+ }
+ else
+ {
+ CodePageInfo->DefaultChar[0] = CodePageEntry->CodePageTable.DefaultChar
& 0xff;
+ CodePageInfo->DefaultChar[1] = 0;
+ }
+
+ if ((CodePageInfo->MaxCharSize =
CodePageEntry->CodePageTable.MaximumCharacterSize) == 2)
+ memcpy(CodePageInfo->LeadByte, CodePageEntry->CodePageTable.LeadByte,
sizeof(CodePageInfo->LeadByte));
+ else
+ CodePageInfo->LeadByte[0] = CodePageInfo->LeadByte[1] = 0;
return TRUE;
}