source: trunk/src/kernel32/codepage.cpp@ 5411

Last change on this file since 5411 was 5411, checked in by sandervl, 24 years ago

codepage workaround (default = 0 isntead of 1252)

File size: 2.0 KB
Line 
1/* $Id: codepage.cpp,v 1.8 2001-03-31 10:39:01 sandervl Exp $
2**
3** Module :CODEPAGE.CPP
4** Abstract :
5**
6** Copyright (C) Vit Timchishin
7**
8** Log: Wed 22/12/1999 Created
9**
10*/
11
12#include <odin.h>
13#include <odinwrap.h>
14#include <os2win.h>
15#include "oslibdos.h"
16//#include "profile.h"
17#include <options.h>
18#include "codepage.h"
19
20#define DBG_LOCALLOG DBG_codepage
21#include "dbglocal.h"
22
23static UconvObject DisplayUconv = NULL;
24static UconvObject WindowsUconv = NULL;
25
26static ULONG windowCodePage = -1;
27static ULONG displayCodePage = -1;
28
29ULONG GetDisplayCodepage()
30{
31 if(displayCodePage == -1) {
32 //default codepage is 1252 (same as default Windows codepage)
33// displayCodePage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "DISPLAY", 1252);
34 displayCodePage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "DISPLAY", 0);
35 }
36 return displayCodePage;
37}
38
39ULONG GetWindowsCodepage()
40{
41 if(windowCodePage == -1) {
42 //default codepage is 1252 (same as default Windows codepage)
43// windowCodePage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "WINDOWS", 1252);
44 windowCodePage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "WINDOWS", 0);
45 }
46 return windowCodePage;
47}
48
49UINT WIN32API GetACP()
50{
51 UINT codepage = GetDisplayCodepage();
52 dprintf(("GetACP -> %d", codepage));
53
54 return(codepage);
55}
56
57static UconvObject GetObjectByCP(ULONG codepage)
58{
59 UconvObject rc = 0;
60 UniChar codepage_str[12];
61
62 BOOL ret = UniMapCpToUcsCp(codepage, codepage_str, sizeof(codepage_str));
63 if ( ret == ULS_SUCCESS )
64 {
65 ret = UniCreateUconvObject( codepage_str, &rc );
66 if ( ret != ULS_SUCCESS )
67 rc = 0;
68 }
69 dprintf(("UniCreateUconvObject for CP %d (%08x)\n", codepage, rc ));
70 return rc;
71}
72
73UconvObject GetDisplayUconvObject()
74{
75 if (!DisplayUconv)
76 DisplayUconv = GetObjectByCP(GetDisplayCodepage());
77
78 return DisplayUconv;
79}
80
81UconvObject GetWindowsUconvObject()
82{
83 if (!WindowsUconv)
84 WindowsUconv = GetObjectByCP(GetWindowsCodepage());
85
86 return WindowsUconv;
87}
88
Note: See TracBrowser for help on using the repository browser.