Line | |
---|
1 | /*
|
---|
2 | ** Module :CODEPAGE.CPP
|
---|
3 | ** Abstract :
|
---|
4 | **
|
---|
5 | ** Copyright (C) Vit Timchishin
|
---|
6 | **
|
---|
7 | ** Log: Wed 22/12/1999 Created
|
---|
8 | **
|
---|
9 | */
|
---|
10 |
|
---|
11 | #include <odin.h>
|
---|
12 | #include <odinwrap.h>
|
---|
13 | #include <os2win.h>
|
---|
14 | #include "oslibdos.h"
|
---|
15 | #include "profile.h"
|
---|
16 | #include "codepage.h"
|
---|
17 |
|
---|
18 | #define DBG_LOCALLOG DBG_codepage
|
---|
19 | #include "dbglocal.h"
|
---|
20 |
|
---|
21 | static UconvObject DisplayUconv = NULL;
|
---|
22 | static UconvObject WindowsUconv = NULL;
|
---|
23 |
|
---|
24 | ULONG GetDisplayCodepage()
|
---|
25 | {
|
---|
26 | static ULONG codepage = -1;
|
---|
27 |
|
---|
28 | if(codepage == -1) {
|
---|
29 | codepage = ODIN_PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "DISPLAY", 0);
|
---|
30 | }
|
---|
31 | return codepage;
|
---|
32 | }
|
---|
33 |
|
---|
34 | ULONG GetWindowsCodepage()
|
---|
35 | {
|
---|
36 | static ULONG codepage = -1;
|
---|
37 |
|
---|
38 | if(codepage == -1) {
|
---|
39 | codepage = ODIN_PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "WINDOWS", 0);
|
---|
40 | }
|
---|
41 | return codepage;
|
---|
42 | }
|
---|
43 |
|
---|
44 | static UconvObject GetObjectByCP(ULONG codepage)
|
---|
45 | {
|
---|
46 | UconvObject rc = 0;
|
---|
47 | UniChar codepage_str[12];
|
---|
48 |
|
---|
49 | BOOL ret = UniMapCpToUcsCp(codepage, codepage_str, sizeof(codepage_str));
|
---|
50 | if ( ret == ULS_SUCCESS )
|
---|
51 | {
|
---|
52 | ret = UniCreateUconvObject( codepage_str, &rc );
|
---|
53 | if ( ret != ULS_SUCCESS )
|
---|
54 | rc = 0;
|
---|
55 | }
|
---|
56 | dprintf(("UniCreateUconvObject for CP %d (%08x)\n", codepage, rc ));
|
---|
57 | return rc;
|
---|
58 | }
|
---|
59 |
|
---|
60 | UconvObject GetDisplayUconvObject()
|
---|
61 | {
|
---|
62 | if (!DisplayUconv)
|
---|
63 | DisplayUconv = GetObjectByCP(GetDisplayCodepage());
|
---|
64 |
|
---|
65 | return DisplayUconv;
|
---|
66 | }
|
---|
67 |
|
---|
68 | UconvObject GetWindowsUconvObject()
|
---|
69 | {
|
---|
70 | if (!WindowsUconv)
|
---|
71 | WindowsUconv = GetObjectByCP(GetWindowsCodepage());
|
---|
72 |
|
---|
73 | return WindowsUconv;
|
---|
74 | }
|
---|
75 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.