2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
17 /***********************************************************************
18 * GetACP (KERNEL32.148)
20 UINT32 WINAPI
GetACP(void)
22 return 1252; /* Windows 3.1 ISO Latin */
25 /***********************************************************************
26 * GetCPInfo (KERNEL32.154)
28 BOOL32 WINAPI
GetCPInfo( UINT32 codepage
, LPCPINFO cpinfo
)
30 cpinfo
->DefaultChar
[0] = '?';
33 case 932 : /* Shift JIS (japan) */
34 cpinfo
->MaxCharSize
= 2;
35 cpinfo
->LeadByte
[0]= 0x81; cpinfo
->LeadByte
[1] = 0x9F;
36 cpinfo
->LeadByte
[2]= 0xE0; cpinfo
->LeadByte
[3] = 0xFC;
37 cpinfo
->LeadByte
[4]= 0x00; cpinfo
->LeadByte
[5] = 0x00;
39 case 936 : /* GB2312 (Chinese) */
40 case 949 : /* KSC5601-1987 (Korean) */
41 case 950 : /* BIG5 (Chinese) */
42 cpinfo
->MaxCharSize
= 2;
43 cpinfo
->LeadByte
[0]= 0x81; cpinfo
->LeadByte
[1] = 0xFE;
44 cpinfo
->LeadByte
[2]= 0x00; cpinfo
->LeadByte
[3] = 0x00;
46 case 1361 : /* Johab (Korean) */
47 cpinfo
->MaxCharSize
= 2;
48 cpinfo
->LeadByte
[0]= 0x84; cpinfo
->LeadByte
[1] = 0xD3;
49 cpinfo
->LeadByte
[2]= 0xD8; cpinfo
->LeadByte
[3] = 0xDE;
50 cpinfo
->LeadByte
[4]= 0xE0; cpinfo
->LeadByte
[5] = 0xF9;
51 cpinfo
->LeadByte
[6]= 0x00; cpinfo
->LeadByte
[7] = 0x00;
54 cpinfo
->MaxCharSize
= 1;
55 cpinfo
->LeadByte
[0]= 0x00; cpinfo
->LeadByte
[1] = 0x00;
61 /***********************************************************************
62 * GetOEMCP (KERNEL32.248)
64 UINT32 WINAPI
GetOEMCP(void)
66 return 437; /* MS-DOS United States */
69 /***********************************************************************
70 * IsValidCodePage (KERNEL32.360)
72 BOOL32 WINAPI
IsValidCodePage(UINT32 CodePage
)
85 /***********************************************************************
86 * MultiByteToWideChar (KERNEL32.392)
88 int WINAPI
MultiByteToWideChar(UINT32 page
, DWORD flags
, char *src
, int srclen
,
89 WCHAR
*dst
, int dstlen
)
92 srclen
= lstrlen32A(src
);
96 lstrcpynAtoW(dst
,src
,srclen
); /* FIXME */
100 int WINAPI
WideCharToMultiByte(UINT32 page
, DWORD flags
, WCHAR
*src
, int srclen
,
101 char *dst
, int dstlen
, char* defchar
, BOOL32
*used
)
104 int dont_copy
= (dstlen
==0);
105 if(page
!=GetACP() && page
!=CP_OEMCP
&& page
!=CP_ACP
)
106 fprintf(stdnimp
,"Conversion in CP %d not supported\n",page
);
109 fprintf(stdnimp
,"WideCharToMultiByte flags %lx not supported\n",flags
);
113 while(srclen
&& (dont_copy
|| dstlen
))
120 /* FIXME: Is this correct ?*/
121 if(flags
& WC_DEFAULTCHAR
){
122 *dst
= defchar
? *defchar
: '?';
132 if(srclen
!=-1)srclen
--;
139 /***********************************************************************
140 * IsDBCSLeadByteEx (KERNEL32.359)
142 BOOL32 WINAPI
IsDBCSLeadByteEx( UINT32 codepage
, BYTE testchar
)
147 GetCPInfo(codepage
, &cpinfo
);
148 for (i
= 0 ; i
< sizeof(cpinfo
.LeadByte
)/sizeof(cpinfo
.LeadByte
[0]); i
+=2)
150 if (cpinfo
.LeadByte
[i
] == 0)
152 if (cpinfo
.LeadByte
[i
] <= testchar
&& testchar
<= cpinfo
.LeadByte
[i
+1])
159 /***********************************************************************
160 * IsDBCSLeadByte16 (KERNEL.207)
162 BOOL16 WINAPI
IsDBCSLeadByte16( BYTE testchar
)
164 return IsDBCSLeadByteEx(GetACP(), testchar
);
168 /***********************************************************************
169 * IsDBCSLeadByte32 (KERNEL32.358)
171 BOOL32 WINAPI
IsDBCSLeadByte32( BYTE testchar
)
173 return IsDBCSLeadByteEx(GetACP(), testchar
);
177 /***********************************************************************
178 * EnumSystemCodePages32A (KERNEL32.92)
180 BOOL32 WINAPI
EnumSystemCodePages32A(CODEPAGE_ENUMPROC32A lpfnCodePageEnum
,DWORD flags
)
182 dprintf_win32(stddeb
,"EnumSystemCodePages32A(%p,%08lx)\n",
183 lpfnCodePageEnum
,flags
185 lpfnCodePageEnum("437");
189 /***********************************************************************
190 * EnumSystemCodePages32W (KERNEL32.93)
192 BOOL32 WINAPI
EnumSystemCodePages32W( CODEPAGE_ENUMPROC32W lpfnCodePageEnum
,
196 dprintf_win32(stddeb
,"EnumSystemCodePages32W(%p,%08lx)\n",
197 lpfnCodePageEnum
,flags
);
199 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, "437" );
200 lpfnCodePageEnum(cp
);
201 HeapFree( GetProcessHeap(), 0, cp
);