| 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 | static UconvObject DisplayUconv = NULL;
|
|---|
| 19 | static UconvObject WindowsUconv = NULL;
|
|---|
| 20 |
|
|---|
| 21 | ULONG GetDisplayCodepage()
|
|---|
| 22 | {
|
|---|
| 23 | static ULONG codepage = -1;
|
|---|
| 24 |
|
|---|
| 25 | if(codepage == -1) {
|
|---|
| 26 | codepage = ODIN_PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "DISPLAY", 0);
|
|---|
| 27 | }
|
|---|
| 28 | return codepage;
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | ULONG GetWindowsCodepage()
|
|---|
| 32 | {
|
|---|
| 33 | static ULONG codepage = -1;
|
|---|
| 34 |
|
|---|
| 35 | if(codepage == -1) {
|
|---|
| 36 | codepage = ODIN_PROFILE_GetOdinIniInt(CODEPAGE_SECTION, "WINDOWS", 0);
|
|---|
| 37 | }
|
|---|
| 38 | return codepage;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | static UconvObject GetObjectByCP(ULONG codepage)
|
|---|
| 42 | {
|
|---|
| 43 | UconvObject rc = 0;
|
|---|
| 44 | UniChar codepage_str[12];
|
|---|
| 45 |
|
|---|
| 46 | BOOL ret = UniMapCpToUcsCp(codepage, codepage_str, sizeof(codepage_str));
|
|---|
| 47 | if ( ret == ULS_SUCCESS )
|
|---|
| 48 | {
|
|---|
| 49 | ret = UniCreateUconvObject( codepage_str, &rc );
|
|---|
| 50 | if ( ret != ULS_SUCCESS )
|
|---|
| 51 | rc = 0;
|
|---|
| 52 | }
|
|---|
| 53 | dprintf(("UniCreateUconvObject for CP %d (%08x)\n", codepage, rc ));
|
|---|
| 54 | return rc;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | UconvObject GetDisplayUconvObject()
|
|---|
| 58 | {
|
|---|
| 59 | if (!DisplayUconv)
|
|---|
| 60 | DisplayUconv = GetObjectByCP(GetDisplayCodepage());
|
|---|
| 61 |
|
|---|
| 62 | return DisplayUconv;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | UconvObject GetWindowsUconvObject()
|
|---|
| 66 | {
|
|---|
| 67 | if (!WindowsUconv)
|
|---|
| 68 | WindowsUconv = GetObjectByCP(GetWindowsCodepage());
|
|---|
| 69 |
|
|---|
| 70 | return WindowsUconv;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.