tagging release
[dasher.git] / trunk / Src / Win32 / Common / DasherEncodingToCP.cpp
blob668be5f6c656465d865943c202cce56446450fef
1 // DasherEncodingToCP.cpp
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #include "WinCommon.h"
11 #include "DasherEncodingToCP.h"
12 #include "WinLocalisation.h"
13 using WinLocalisation::GetUserCodePage;
15 // Track memory leaks on Windows to the line that new'd the memory
16 #ifdef _WIN32
17 #ifdef _DEBUG
18 #define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
19 #define new DEBUG_NEW
20 #undef THIS_FILE
21 static char THIS_FILE[] = __FILE__;
22 #endif
23 #endif
25 UINT EncodingToCP(Dasher::Opts::AlphabetTypes Encoding) {
26 using namespace Dasher;
27 using namespace Opts;
29 UINT CodePage;
31 switch (Encoding) {
33 case UTF8: // Just return Unicode Codepages
34 return 65001;
35 break;
36 case UTF16LE:
37 return 1200;
38 break;
39 case UTF16BE:
40 return 1201;
41 break;
43 case MyNone:
44 CodePage = GetUserCodePage();
45 break;
46 case Arabic: // The rest need checking. Return
47 CodePage = 1256; // user codepage if not installed.
48 break;
49 case Baltic:
50 CodePage = 1257;
51 break;
52 case CentralEurope:
53 CodePage = 1250;
54 break;
55 case ChineseSimplified:
56 CodePage = 936;
57 break;
58 case ChineseTraditional:
59 CodePage = 950;
60 break;
61 case Cyrillic:
62 CodePage = 1251;
63 break;
64 case Greek:
65 CodePage = 1253;
66 break;
67 case Hebrew:
68 CodePage = 1255;
69 break;
70 case Japanese:
71 CodePage = 932;
72 break;
73 case Korean:
74 CodePage = 949;
75 break;
76 case Thai:
77 CodePage = 874;
78 break;
79 case Turkish:
80 CodePage = 1254;
81 break;
82 case VietNam:
83 CodePage = 1258;
84 break;
85 case Western:
86 CodePage = 1252;
87 break;
88 default:
89 CodePage = GetUserCodePage();
90 break;
93 if(!IsValidCodePage(CodePage))
94 CodePage = GetUserCodePage();
96 return CodePage;