Release 961222
[wine/gsoc-2012-control.git] / win32 / code_page.c
blobda1d7e0aa79288619a512697d662bde42cbd2c04
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 */
7 #include <stdio.h>
8 #include <malloc.h>
9 #include "windows.h"
10 #include "winerror.h"
11 #include "winnls.h"
12 #include "heap.h"
13 #include "stddebug.h"
14 #include "debug.h"
17 /***********************************************************************
18 * GetACP (KERNEL32.148)
20 UINT32 GetACP(void)
22 return 1252; /* Windows 3.1 ISO Latin */
25 /***********************************************************************
26 * GetCPInfo (KERNEL32.154)
28 BOOL GetCPInfo(UINT codepage, LPCPINFO cpinfo)
30 cpinfo->MaxCharSize = 1;
31 cpinfo->DefaultChar[0] = '?';
33 return 1;
36 /***********************************************************************
37 * GetOEMCP (KERNEL32.248)
39 UINT32 GetOEMCP(void)
41 return 437; /* MS-DOS United States */
44 /***********************************************************************
45 * MultiByteToWideChar (KERNEL32.392)
47 int MultiByteToWideChar(UINT page, DWORD flags, char *src, int srclen,
48 WCHAR *dst, int dstlen)
50 return (srclen==-1) ? strlen(src) * 2: srclen*2;
53 int WideCharToMultiByte(UINT page, DWORD flags, WCHAR *src, int srclen,
54 char *dst, int dstlen, char* defchar, BOOL *used)
56 int count = 0;
57 int dont_copy= (dstlen==0);
58 if(page!=GetACP() && page!=CP_OEMCP && page!=CP_ACP)
59 fprintf(stdnimp,"Conversion in CP %d not supported\n",page);
60 if(flags)
61 fprintf(stdnimp,"WideCharToMultiByte flags %lx not supported\n",flags);
62 if(used)
63 *used=0;
64 while(srclen && (dont_copy || dstlen))
66 if(!dont_copy){
67 if(*src<256)
68 *dst = *src;
69 else
71 /* FIXME: Is this correct ?*/
72 if(flags & WC_DEFAULTCHAR){
73 *dst = defchar ? *defchar : '?';
74 if(used)*used=1;
77 dstlen--;
78 dst++;
80 count++;
81 if(!*src)
82 break;
83 if(srclen!=-1)srclen--;
84 src++;
86 return count;
89 /***********************************************************************
90 * EnumSystemCodePages32A (KERNEL32.92)
92 BOOL32
93 EnumSystemCodePages32A(CODEPAGE_ENUMPROC32A lpfnCodePageEnum,DWORD flags) {
94 dprintf_win32(stddeb,"EnumSystemCodePages32A(%p,%08lx)\n",
95 lpfnCodePageEnum,flags
97 lpfnCodePageEnum("437");
98 return TRUE;
101 /***********************************************************************
102 * EnumSystemCodePages32W (KERNEL32.93)
104 BOOL32
105 EnumSystemCodePages32W( CODEPAGE_ENUMPROC32W lpfnCodePageEnum, DWORD flags)
107 WCHAR *cp;
108 dprintf_win32(stddeb,"EnumSystemCodePages32W(%p,%08lx)\n",
109 lpfnCodePageEnum,flags );
111 cp = HEAP_strdupAtoW( GetProcessHeap(), 0, "437" );
112 lpfnCodePageEnum(cp);
113 HeapFree( GetProcessHeap(), 0, cp );
114 return TRUE;