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

Last change on this file since 5023 was 5023, checked in by sandervl, 25 years ago

default display & window codepage set to 1252

File size: 1.7 KB
Line 
1/* $Id: codepage.cpp,v 1.7 2001-01-24 20:33:37 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
26ULONG GetDisplayCodepage()
27{
28 static ULONG codepage = -1;
29
30 if(codepage == -1) {
31 //default codepage is 1252 (same as default Windows codepage)
32 codepage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "DISPLAY", 1252);
33 }
34 return codepage;
35}
36
37ULONG GetWindowsCodepage()
38{
39 static ULONG codepage = -1;
40
41 if(codepage == -1) {
42 //default codepage is 1252 (same as default Windows codepage)
43 codepage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "WINDOWS", 1252);
44 }
45 return codepage;
46}
47
48static UconvObject GetObjectByCP(ULONG codepage)
49{
50 UconvObject rc = 0;
51 UniChar codepage_str[12];
52
53 BOOL ret = UniMapCpToUcsCp(codepage, codepage_str, sizeof(codepage_str));
54 if ( ret == ULS_SUCCESS )
55 {
56 ret = UniCreateUconvObject( codepage_str, &rc );
57 if ( ret != ULS_SUCCESS )
58 rc = 0;
59 }
60 dprintf(("UniCreateUconvObject for CP %d (%08x)\n", codepage, rc ));
61 return rc;
62}
63
64UconvObject GetDisplayUconvObject()
65{
66 if (!DisplayUconv)
67 DisplayUconv = GetObjectByCP(GetDisplayCodepage());
68
69 return DisplayUconv;
70}
71
72UconvObject GetWindowsUconvObject()
73{
74 if (!WindowsUconv)
75 WindowsUconv = GetObjectByCP(GetWindowsCodepage());
76
77 return WindowsUconv;
78}
79
Note: See TracBrowser for help on using the repository browser.