| 1 | /* $Id: codepage.cpp,v 1.9 2001-04-01 12:33:10 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 |
|
|---|
| 23 | static UconvObject DisplayUconv = NULL;
|
|---|
| 24 | static UconvObject WindowsUconv = NULL;
|
|---|
| 25 |
|
|---|
| 26 | static ULONG windowCodePage = -1;
|
|---|
| 27 | static ULONG displayCodePage = -1;
|
|---|
| 28 |
|
|---|
| 29 | ULONG 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 |
|
|---|
| 39 | ULONG 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 |
|
|---|
| 49 | UINT WIN32API GetACP()
|
|---|
| 50 | {
|
|---|
| 51 | UINT codepage = GetDisplayCodepage();
|
|---|
| 52 | dprintf(("GetACP -> %d", codepage));
|
|---|
| 53 |
|
|---|
| 54 | return(codepage);
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | static 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 |
|
|---|
| 73 | UconvObject GetDisplayUconvObject()
|
|---|
| 74 | {
|
|---|
| 75 | if (!DisplayUconv)
|
|---|
| 76 | DisplayUconv = GetObjectByCP(GetDisplayCodepage());
|
|---|
| 77 |
|
|---|
| 78 | return DisplayUconv;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | UconvObject GetWindowsUconvObject()
|
|---|
| 82 | {
|
|---|
| 83 | if (!WindowsUconv)
|
|---|
| 84 | WindowsUconv = GetObjectByCP(GetWindowsCodepage());
|
|---|
| 85 |
|
|---|
| 86 | return WindowsUconv;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|