Release 960324
[wine] / win32 / code_page.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis and Cameron Heide
5  */
6
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"
14
15
16 /***********************************************************************
17  *           GetACP               (KERNEL32.148)
18  */
19 UINT GetACP(void)
20 {
21     return 1252;    /* Windows 3.1 ISO Latin */
22 }
23
24 /***********************************************************************
25  *           GetCPInfo            (KERNEL32.154)
26  */
27 BOOL GetCPInfo(UINT codepage, LPCPINFO cpinfo)
28 {
29     cpinfo->MaxCharSize = 1;
30     cpinfo->DefaultChar[0] = '?';
31
32     return 1;
33 }
34
35 /***********************************************************************
36  *              GetOEMCP                (KERNEL32.248)
37  */
38 UINT GetOEMCP(void)
39 {
40     return 437;    /* MS-DOS United States */
41 }
42
43 /***********************************************************************
44  *              MultiByteToWideChar                (KERNEL32.392)
45  */
46 int MultiByteToWideChar(UINT page, DWORD flags, char *src, int srclen,
47                         WCHAR *dst, int dstlen)
48 {
49     return (srclen==-1) ? strlen(src) * 2: srclen*2; 
50 }
51
52 int WideCharToMultiByte(UINT page, DWORD flags, WCHAR *src, int srclen,
53                                                 char *dst, int dstlen, char* defchar, BOOL *used)
54 {
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))
64         {
65                 if(!dont_copy){
66                         if(*src<256)
67                                 *dst = *src;
68                         else
69                         {
70                                 /* FIXME: Is this correct ?*/
71                                 if(flags & WC_DEFAULTCHAR){
72                                         *dst = defchar ? *defchar : '?';
73                                         if(used)*used=1;
74                                 }
75                         }
76                         dstlen--;
77                         dst++;
78                 }
79                 count++;
80                 if(!*src)
81                         break;
82                 if(srclen!=-1)srclen--;
83                 src++;
84         }
85         return count;
86 }
87
88