Release 960606
[wine.git] / win32 / code_page.c
blob43dc261b1961f1d7f82f79e6ddb41e61521a291f
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 */
7 #include <stdio.h>
8 #include "windows.h"
9 #include "winerror.h"
10 #include "kernel32.h"
11 #include "winnls.h"
12 #include "stddebug.h"
13 #include "debug.h"
16 /***********************************************************************
17 * GetACP (KERNEL32.148)
19 UINT GetACP(void)
21 return 1252; /* Windows 3.1 ISO Latin */
24 /***********************************************************************
25 * GetCPInfo (KERNEL32.154)
27 BOOL GetCPInfo(UINT codepage, LPCPINFO cpinfo)
29 cpinfo->MaxCharSize = 1;
30 cpinfo->DefaultChar[0] = '?';
32 return 1;
35 /***********************************************************************
36 * GetOEMCP (KERNEL32.248)
38 UINT GetOEMCP(void)
40 return 437; /* MS-DOS United States */
43 /***********************************************************************
44 * MultiByteToWideChar (KERNEL32.392)
46 int MultiByteToWideChar(UINT page, DWORD flags, char *src, int srclen,
47 WCHAR *dst, int dstlen)
49 return (srclen==-1) ? strlen(src) * 2: srclen*2;
52 int WideCharToMultiByte(UINT page, DWORD flags, WCHAR *src, int srclen,
53 char *dst, int dstlen, char* defchar, BOOL *used)
55 int count = 0;
56 int dont_copy= (dstlen==0);
57 if(page!=GetACP() && page!=CP_OEMCP && page!=CP_ACP)
58 fprintf(stdnimp,"Conversion in CP %d not supported\n",page);
59 if(flags)
60 fprintf(stdnimp,"WideCharToMultiByte flags %lx not supported\n",flags);
61 if(used)
62 *used=0;
63 while(srclen && (dont_copy || dstlen))
65 if(!dont_copy){
66 if(*src<256)
67 *dst = *src;
68 else
70 /* FIXME: Is this correct ?*/
71 if(flags & WC_DEFAULTCHAR){
72 *dst = defchar ? *defchar : '?';
73 if(used)*used=1;
76 dstlen--;
77 dst++;
79 count++;
80 if(!*src)
81 break;
82 if(srclen!=-1)srclen--;
83 src++;
85 return count;