1 | /* $Id: codepage.cpp,v 1.6 2000-10-02 21:40:57 phaller 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 |
|
---|
23 | static UconvObject DisplayUconv = NULL;
|
---|
24 | static UconvObject WindowsUconv = NULL;
|
---|
25 |
|
---|
26 | ULONG GetDisplayCodepage()
|
---|
27 | {
|
---|
28 | static ULONG codepage = -1;
|
---|
29 |
|
---|
30 | if(codepage == -1) {
|
---|
31 | codepage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "DISPLAY", 0);
|
---|
32 | }
|
---|
33 | return codepage;
|
---|
34 | }
|
---|
35 |
|
---|
36 | ULONG GetWindowsCodepage()
|
---|
37 | {
|
---|
38 | static ULONG codepage = -1;
|
---|
39 |
|
---|
40 | if(codepage == -1) {
|
---|
41 | codepage = PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "WINDOWS", 0);
|
---|
42 | }
|
---|
43 | return codepage;
|
---|
44 | }
|
---|
45 |
|
---|
46 | static UconvObject GetObjectByCP(ULONG codepage)
|
---|
47 | {
|
---|
48 | UconvObject rc = 0;
|
---|
49 | UniChar codepage_str[12];
|
---|
50 |
|
---|
51 | BOOL ret = UniMapCpToUcsCp(codepage, codepage_str, sizeof(codepage_str));
|
---|
52 | if ( ret == ULS_SUCCESS )
|
---|
53 | {
|
---|
54 | ret = UniCreateUconvObject( codepage_str, &rc );
|
---|
55 | if ( ret != ULS_SUCCESS )
|
---|
56 | rc = 0;
|
---|
57 | }
|
---|
58 | dprintf(("UniCreateUconvObject for CP %d (%08x)\n", codepage, rc ));
|
---|
59 | return rc;
|
---|
60 | }
|
---|
61 |
|
---|
62 | UconvObject GetDisplayUconvObject()
|
---|
63 | {
|
---|
64 | if (!DisplayUconv)
|
---|
65 | DisplayUconv = GetObjectByCP(GetDisplayCodepage());
|
---|
66 |
|
---|
67 | return DisplayUconv;
|
---|
68 | }
|
---|
69 |
|
---|
70 | UconvObject GetWindowsUconvObject()
|
---|
71 | {
|
---|
72 | if (!WindowsUconv)
|
---|
73 | WindowsUconv = GetObjectByCP(GetWindowsCodepage());
|
---|
74 |
|
---|
75 | return WindowsUconv;
|
---|
76 | }
|
---|
77 |
|
---|