2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
16 /***********************************************************************
17 * GetACP (KERNEL32.148)
19 UINT32 WINAPI
GetACP(void)
21 return 1252; /* Windows 3.1 ISO Latin */
24 /***********************************************************************
25 * GetCPInfo (KERNEL32.154)
27 BOOL32 WINAPI
GetCPInfo( UINT32 codepage
, LPCPINFO cpinfo
)
29 cpinfo
->DefaultChar
[0] = '?';
32 case 932 : /* Shift JIS (japan) */
33 cpinfo
->MaxCharSize
= 2;
34 cpinfo
->LeadByte
[0]= 0x81; cpinfo
->LeadByte
[1] = 0x9F;
35 cpinfo
->LeadByte
[2]= 0xE0; cpinfo
->LeadByte
[3] = 0xFC;
36 cpinfo
->LeadByte
[4]= 0x00; cpinfo
->LeadByte
[5] = 0x00;
38 case 936 : /* GB2312 (Chinese) */
39 case 949 : /* KSC5601-1987 (Korean) */
40 case 950 : /* BIG5 (Chinese) */
41 cpinfo
->MaxCharSize
= 2;
42 cpinfo
->LeadByte
[0]= 0x81; cpinfo
->LeadByte
[1] = 0xFE;
43 cpinfo
->LeadByte
[2]= 0x00; cpinfo
->LeadByte
[3] = 0x00;
45 case 1361 : /* Johab (Korean) */
46 cpinfo
->MaxCharSize
= 2;
47 cpinfo
->LeadByte
[0]= 0x84; cpinfo
->LeadByte
[1] = 0xD3;
48 cpinfo
->LeadByte
[2]= 0xD8; cpinfo
->LeadByte
[3] = 0xDE;
49 cpinfo
->LeadByte
[4]= 0xE0; cpinfo
->LeadByte
[5] = 0xF9;
50 cpinfo
->LeadByte
[6]= 0x00; cpinfo
->LeadByte
[7] = 0x00;
53 cpinfo
->MaxCharSize
= 1;
54 cpinfo
->LeadByte
[0]= 0x00; cpinfo
->LeadByte
[1] = 0x00;
60 /***********************************************************************
61 * GetOEMCP (KERNEL32.248)
63 UINT32 WINAPI
GetOEMCP(void)
65 return 437; /* MS-DOS United States */
68 /***********************************************************************
69 * IsValidCodePage (KERNEL32.360)
71 BOOL32 WINAPI
IsValidCodePage(UINT32 CodePage
)
84 /***********************************************************************
85 * MultiByteToWideChar (KERNEL32.392)
87 INT32 WINAPI
MultiByteToWideChar(UINT32 page
, DWORD flags
,
88 LPCSTR src
, INT32 srclen
,
89 LPWSTR dst
, INT32 dstlen
)
94 srclen
= lstrlen32A(src
)+1;
99 while (srclen
> 0 && dstlen
> 0) {
100 *dst
= (WCHAR
)(unsigned char)*src
;
107 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
113 INT32 WINAPI
WideCharToMultiByte(UINT32 page
, DWORD flags
, LPCWSTR src
,
114 INT32 srclen
,LPSTR dst
, INT32 dstlen
,
115 LPCSTR defchar
, BOOL32
*used
)
119 int dont_copy
= (dstlen
==0);
120 if (page
!=GetACP() && page
!=CP_OEMCP
&& page
!=CP_ACP
)
121 fprintf(stdnimp
,"Conversion in CP %d not supported\n",page
);
124 fprintf(stdnimp
,"WideCharToMultiByte flags %lx not supported\n",flags
);
129 srclen
= lstrlen32W(src
)+1;
130 while(srclen
&& (dont_copy
|| dstlen
))
137 /* ??? The WC_DEFAULTCHAR flag only gets used in
138 * combination with the WC_COMPOSITECHECK flag or at
139 * least this is what it seems from using the function
140 * on NT4.0 in combination with reading the documentation.
142 *dst
= defchar
? *defchar
: '?';
159 if (!eos
&& srclen
> 0) {
160 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
167 /***********************************************************************
168 * IsDBCSLeadByteEx (KERNEL32.359)
170 BOOL32 WINAPI
IsDBCSLeadByteEx( UINT32 codepage
, BYTE testchar
)
175 GetCPInfo(codepage
, &cpinfo
);
176 for (i
= 0 ; i
< sizeof(cpinfo
.LeadByte
)/sizeof(cpinfo
.LeadByte
[0]); i
+=2)
178 if (cpinfo
.LeadByte
[i
] == 0)
180 if (cpinfo
.LeadByte
[i
] <= testchar
&& testchar
<= cpinfo
.LeadByte
[i
+1])
187 /***********************************************************************
188 * IsDBCSLeadByte16 (KERNEL.207)
190 BOOL16 WINAPI
IsDBCSLeadByte16( BYTE testchar
)
192 return IsDBCSLeadByteEx(GetACP(), testchar
);
196 /***********************************************************************
197 * IsDBCSLeadByte32 (KERNEL32.358)
199 BOOL32 WINAPI
IsDBCSLeadByte32( BYTE testchar
)
201 return IsDBCSLeadByteEx(GetACP(), testchar
);
205 /***********************************************************************
206 * EnumSystemCodePages32A (KERNEL32.92)
208 BOOL32 WINAPI
EnumSystemCodePages32A(CODEPAGE_ENUMPROC32A lpfnCodePageEnum
,DWORD flags
)
210 TRACE(win32
,"(%p,%08lx)\n",
211 lpfnCodePageEnum
,flags
213 lpfnCodePageEnum("437");
217 /***********************************************************************
218 * EnumSystemCodePages32W (KERNEL32.93)
220 BOOL32 WINAPI
EnumSystemCodePages32W( CODEPAGE_ENUMPROC32W lpfnCodePageEnum
,
224 TRACE(win32
,"(%p,%08lx)\n",
225 lpfnCodePageEnum
,flags
);
227 cp
= HEAP_strdupAtoW( GetProcessHeap(), 0, "437" );
228 lpfnCodePageEnum(cp
);
229 HeapFree( GetProcessHeap(), 0, cp
);