update tizen source
[framework/messaging/msg-service.git] / plugin / mms_plugin / LanguagePack / MmsPluginWmLngLatinUni.cpp
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31 #include "MsgDebug.h"
32 #include "MmsPluginWmLngPack.h"
33 #include "MmsPluginMessage.h"
34 #include <stdlib.h>
35
36
37 #define         MAX_ASCII                       256
38 #define         MAX_ASCII_NUM           255
39
40 static void      __WmLngReverseKeyCode(UCHAR *pOutStr, MCHAR *pInputStr, UINT len);
41 static UINT      __WmLngLatin12UnicodeN(MCHAR *pOutStr, UCHAR *pInputStr, UINT len);
42 static int       __WmLngConvertLatin12Unicode (MCHAR *des, UCHAR *str, UINT len);
43
44 #define tabLatin2UniMax 93
45 #define tabLatin3UniMax 87
46 #define tabLatin4UniMax 96
47 #define tabLatin8UniMax 60
48 #define tabLatin15UniMax 96
49 #define tabLatin5UniMax 96
50 #define tabWin1251UniMax 128
51 #define tabKoi8rUniMax 128
52 #define tabKoi8uUniMax 128
53
54 #define SIM_SMSP_ALPHA_ID_MAX_LEN 30
55 #define SMS_MCHAR_TO_SIM_ALPHA_MASK 0x80
56 #define SMS_SIM_ALPHA_TO_MCHAR_MASK 0x7F
57
58
59 /* latin2 table */
60 typedef struct {
61         UCHAR latin2;
62         MCHAR unicode;
63 }Latin2UniTable;
64
65 const Latin2UniTable tabLatin2Uni[] = {
66         {0xA0,0x0020},{0xA1,0x0104},{0xA3,0x0141},{0xA4,0x00A4},{0xA5,0x013D},
67         {0xA6,0x015A},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0160},{0xAA,0x015E},
68         {0xAB,0x0164},{0xAC,0x0179},{0xAD,0x00AD},{0xAE,0x017D},{0xAF,0x017B},
69         {0xB0,0x00B0},{0xB1,0x0105},{0xB2,0x00B8},{0xB3,0x0142},{0xB4,0x00B4},
70         {0xB5,0x012D},{0xB7,0x015B},{0xB8,0x00B8},{0xB9,0x0161},{0xBA,0x015F},
71         {0xBB,0x0165},{0xBC,0x017A},{0xBE,0x017E},{0xBF,0x017C},{0xC0,0x0154},
72         {0xC1,0x00C1},{0xC2,0x00C2},{0xC3,0x0102},{0xC4,0x00C4},{0xC5,0x0139},
73         {0xC6,0x0106},{0xC7,0x00C7},{0xC8,0x010C},{0xC9,0x00C9},{0xCA,0x0118},
74         {0xCB,0x00CB},{0xCC,0x0114},{0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x010E},
75         {0xD0,0x00D0},{0xD1,0x0143},{0xD2,0x0147},{0xD3,0x00D3},{0xD4,0x00D4},
76         {0xD5,0x0150},{0xD6,0x00D6},{0xD7,0x00D7},{0xD8,0x0158},{0xD9,0x016E},
77         {0xDA,0x00DA},{0xDB,0x0170},{0xDC,0x00DC},{0xDD,0x00DD},{0xDE,0x0162},
78         {0xDF,0x00DF},{0xE0,0x0155},{0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x0103},
79         {0xE4,0x00E4},{0xE5,0x013A},{0xE6,0x0107},{0xE7,0x00E7},{0xE8,0x010D},
80         {0xE9,0x00E9},{0xEA,0x0119},{0xEB,0x00EB},{0xEC,0x011B},{0xED,0x00ED},
81         {0xEE,0x00EE},{0xEF,0x010F},{0xF0,0x0111},{0xF1,0x0144},{0xF2,0x0148},
82         {0xF3,0x00F3},{0xF4,0x00F4},{0xF5,0x0151},{0xF6,0x00F6},{0xF7,0x00F7},
83         {0xF8,0x0159},{0xF9,0x016F},{0xFA,0x00FA},{0xFB,0x0171},{0xFC,0x00FC},
84         {0xFD,0x00FD},{0xFE,0x0163},{0xFF,0x00B7},
85 };
86
87 /* latin3 table */
88 typedef struct {
89         UCHAR latin3;
90         MCHAR unicode;
91 }Latin3UniTable;
92
93 const Latin3UniTable tabLatin3Uni[] = {
94         {0xA0,0x0020},{0xA1,0x0126},{0xA2,0x02D8},{0xA3,0x00A3},{0xA4,0x00A4},
95         {0xA6,0x0124},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0130},{0xAA,0x015E},
96         {0xAB,0x011E},{0xAC,0x0134},{0xAD,0x00AD},{0xAF,0x017B},{0xB0,0x00B0},
97         {0xB1,0x0127},{0xB2,0x00B2},{0xB3,0x00B3},{0xB4,0x00B4},{0xB5,0x00B5},
98         {0xB6,0x0125},{0xB7,0x00B7},{0xB8,0x00B8},{0xB9,0x0131},{0xBA,0x015F},
99         {0xBB,0x011F},{0xBC,0x0135},{0xBD,0x00BD},{0xBF,0x017C},{0xC0,0x00C0},
100         {0xC1,0x00C1},{0xC2,0x00C2},{0xC4,0x00C4},{0xC5,0x010A},{0xC6,0x0108},
101         {0xC7,0x00C7},{0xC8,0x00C8},{0xC9,0x00C9},{0xCA,0x00CA},{0xCB,0x00CB},
102         {0xCC,0x00CC},{0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x00CF},{0xD1,0x00D1},
103         {0xD2,0x00D2},{0xD3,0x00D3},{0xD4,0x00D4},{0xD6,0x00D6},{0xD7,0x00D7},
104         {0xD8,0x011C},{0xD9,0x00D9},{0xDA,0x00DA},{0xDB,0x00DB},{0xDC,0x00DC},
105         {0xDE,0x015C},{0xDF,0x00DF},{0xE0,0x00E0},{0xE1,0x00E1},{0xE2,0x00E2},
106         {0xE4,0x00E4},{0xE5,0x010B},{0xE6,0x0109},{0xE7,0x00E7},{0xE8,0x00E8},
107         {0xE9,0x00E9},{0xEA,0x00EA},{0xEB,0x00EB},{0xEC,0x00EC},{0xED,0x00ED},
108         {0xEE,0x00EE},{0xEF,0x00EF},{0xF1,0x00F1},{0xF2,0x00F2},{0xF3,0x00F3},
109         {0xF4,0x00F4},{0xF5,0x0121},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x011D},
110         {0xF9,0x00F9},{0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x016D},
111         {0xFE,0x015D},{0xFF,0x02D9},
112 };
113 /* latin4 table */
114 typedef struct {
115         UCHAR latin4;
116         MCHAR unicode;
117 }Latin4UniTable;
118
119 const Latin4UniTable tabLatin4Uni[] = {
120         {0xA0,0x0020},{0xA1,0x0104},{0xA2,0x0138},{0xA3,0x0156},{0xA4,0x00A4},
121         {0xA5,0x0128},{0xA6,0x013B},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0160},
122         {0xAA,0x0112},{0xAB,0x0122},{0xAC,0x0166},{0xAD,0x00AD},{0xAE,0x017D},
123         {0xAF,0x00AF},{0xB0,0x00B0},{0xB1,0x0105},{0xB2,0x02DB},{0xB3,0x0157},
124         {0xB4,0x00B4},{0xB5,0x0129},{0xB6,0x013C},{0xB7,0x02C7},{0xB8,0x00B8},
125         {0xB9,0x0161},{0xBA,0x0113},{0xBB,0x0123},{0xBC,0x0167},{0xBD,0x014A},
126         {0xBE,0x017E},{0xBF,0x014B},{0xC0,0x0100},{0xC1,0x00C1},{0xC2,0x00C2},
127         {0xC3,0x00C3},{0xC4,0x00C4},{0xC5,0x00C5},{0xC6,0x00C6},{0xC7,0x012E},
128         {0xC8,0x010C},{0xC9,0x00C9},{0xCA,0x0118},{0xCB,0x00CB},{0xCC,0x0116},
129         {0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x012A},{0xD0,0x0110},{0xD1,0x0145},
130         {0xD2,0x014C},{0xD3,0x0136},{0xD4,0x00D4},{0xD5,0x00D5},{0xD6,0x00D6},
131         {0xD7,0x00D7},{0xD8,0x00D8},{0xD9,0x0172},{0xDA,0x00DA},{0xDB,0x00DB},
132         {0xDC,0x00DC},{0xDD,0x0168},{0xDE,0x016A},{0xDF,0x00DF},{0xE0,0x0101},
133         {0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x00E3},{0xE4,0x00E4},{0xE5,0x00E5},
134         {0xE6,0x00E6},{0xE7,0x012F},{0xE8,0x010D},{0xE9,0x00E9},{0xEA,0x0119},
135         {0xEB,0x00EB},{0xEC,0x0117},{0xED,0x00ED},{0xEE,0x00EE},{0xEF,0x012B},
136         {0xF0,0x0111},{0xF1,0x0146},{0xF2,0x014D},{0xF3,0x0137},{0xF4,0x00F4},
137         {0xF5,0x00F5},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x00F8},{0xF9,0x0173},
138         {0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x0169},{0xFE,0x016B},
139         {0xFF,0x02D9},
140
141 };
142 /* latin8 table */
143 typedef struct {
144         UCHAR latin8;
145         MCHAR unicode;
146 }Latin8UniTable;
147
148 const Latin8UniTable tabLatin8Uni[] = {
149         {0xA0,0x0020},{0xA2,0x00A2},{0xA3,0x00A3},{0xA4,0x00A4},{0xA5,0x00A5},
150         {0xA6,0x00A6},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x00A9},{0xAA,0x00D7},
151         {0xAB,0x00AB},{0xAC,0x00AC},{0xAD,0x00AD},{0xAE,0x00AE},{0xAF,0x203E},
152         {0xB0,0x00B0},{0xB1,0x00B1},{0xB2,0x00B2},{0xB3,0x00B3},{0xB4,0x00B4},
153         {0xB5,0x00B5},{0xB6,0x00B6},{0xB7,0x00B7},{0xB8,0x00B8},{0xB9,0x00B9},
154         {0xBA,0x00F7},{0xBB,0x00BB},{0xBC,0x00BC},{0xBD,0x00BD},{0xBE,0x00BE},
155         {0xDF,0x2017},{0xE0,0x05D0},{0xE1,0x05D1},{0xE2,0x05D2},{0xE3,0x05D3},
156         {0xE4,0x05D4},{0xE5,0x05D5},{0xE6,0x05D6},{0xE7,0x05D7},{0xE8,0x05D8},
157         {0xE9,0x05D9},{0xEA,0x05DA},{0xEB,0x05DB},{0xEC,0x05DC},{0xED,0x05DD},
158         {0xEE,0x05DE},{0xEF,0x05DF},{0xF0,0x05E0},{0xF1,0x05E1},{0xF2,0x05E2},
159         {0xF3,0x05E3},{0xF4,0x05E4},{0xF5,0x05E5},{0xF6,0x05E6},{0xF7,0x05E7},
160         {0xF8,0x05E8},{0xF9,0x05E9},{0xFA,0x05EA},{0xFD,0x200E},{0xFE,0x200F},
161 };
162
163 /* latin15 table */
164 typedef struct {
165         UCHAR latin15;
166         MCHAR unicode;
167 }Latin15UniTable;
168
169 const Latin15UniTable tabLatin15Uni[] = {
170         {0xA0,0x0020},{0xA1,0x00A1},{0xA2,0x00A2},{0xA3,0x00A3},{0xA4,0x20AC},
171         {0xA5,0x00A5},{0xA6,0x0160},{0xA7,0x00A7},{0xA8,0x0161},{0xA9,0x00A9},
172         {0xAA,0x00AA},{0xAB,0x00AB},{0xAC,0x00AC},{0xAD,0x00AD},{0xAE,0x00AE},
173         {0xAF,0x00AF},{0xB0,0x00B0},{0xB1,0x00B1},{0xB2,0x00B2},{0xB3,0x00B3},
174         {0xB4,0x017D},{0xB5,0x00B5},{0xB6,0x00B6},{0xB7,0x00B7},{0xB8,0x017E},
175         {0xB9,0x00B9},{0xBA,0x00BA},{0xBB,0x00BB},{0xBC,0x0152},{0xBD,0x0153},
176         {0xBE,0x0178},{0xBF,0x00BF},{0xC0,0x00C0},{0xC1,0x00C1},{0xC2,0x00C2},
177         {0xC3,0x00C3},{0xC4,0x00C4},{0xC5,0x00C5},{0xC6,0x00C6},{0xC7,0x00C7},
178         {0xC8,0x00C8},{0xC9,0x00C9},{0xCA,0x00CA},{0xCB,0x00CB},{0xCC,0x00CC},
179         {0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x00CF},{0xD0,0x00D0},{0xD1,0x00D1},
180         {0xD2,0x00D2},{0xD3,0x00D3},{0xD4,0x00D4},{0xD5,0x00D5},{0xD6,0x00D6},
181         {0xD7,0x00D7},{0xD8,0x00D8},{0xD9,0x00D9},{0xDA,0x00DA},{0xDB,0x00DB},
182         {0xDC,0x00DC},{0xDD,0x00DD},{0xDE,0x00DE},{0xDF,0x00DF},{0xE0,0x00E0},
183         {0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x00E3},{0xE4,0x00E4},{0xE5,0x00E5},
184         {0xE6,0x00E6},{0xE7,0x00E7},{0xE8,0x00E8},{0xE9,0x00E9},{0xEA,0x00EA},
185         {0xEB,0x00EB},{0xEC,0x00EC},{0xED,0x00ED},{0xEE,0x00EE},{0xEF,0x00EF},
186         {0xF0,0x00F0},{0xF1,0x00F1},{0xF2,0x00F2},{0xF3,0x00F3},{0xF4,0x00F4},
187         {0xF5,0x00F5},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x00F8},{0xF9,0x00F9},
188         {0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x00FD},{0xFE,0x00FE},
189         {0xFF,0x00FF},
190 };
191
192
193 /* Win1251 table */
194 typedef struct {
195         UCHAR win1251;
196         MCHAR unicode;
197 }Win1251UniTable;
198 const Win1251UniTable tabWin1251Uni[] = {
199         {0x80,0x0402},{0x81,0x0403},{0x82,0x201A},{0x83,0x0453},{0x84,0x201E},
200         {0x85,0x2026},{0x86,0x2020},{0x87,0x2021},{0x88,0x20AC},{0x89,0x2030},
201         {0x8A,0x0409},{0x8B,0x2039},{0x8C,0x040A},{0x8D,0x040C},{0x8E,0x040B},
202         {0x8F,0x040F},{0x90,0x0452},{0x91,0x2018},{0x92,0x2019},{0x93,0x201C},
203         {0x94,0x201D},{0x95,0x2022},{0x96,0x2013},{0x97,0x2014},{0x98,0x0000},
204         {0x99,0x2122},{0x9A,0x0459},{0x9B,0x203A},{0x9C,0x045A},{0x9D,0x045C},
205         {0x9E,0x045B},{0x9F,0x045F},{0xA0,0x00a0},{0xA1,0x040e},{0xA2,0x045e},
206         {0xA3,0x0408},{0xA4,0x00a4},{0xA5,0x0490},{0xA6,0x00a6},{0xA7,0x00a7},
207         {0xA8,0x0401},{0xA9,0x00a9},{0xAA,0x0404},{0xAB,0x00ab},{0xAC,0x00ac},
208         {0xAD,0x00ad},{0xAE,0x00ae},{0xAF,0x0407},{0xB0,0x00b0},{0xB1,0x00b1},
209         {0xB2,0x0406},{0xB3,0x0456},{0xB4,0x0491},{0xB5,0x00b5},{0xB6,0x00b6},
210         {0xB7,0x00b7},{0xB8,0x0451},{0xB9,0x2116},{0xBA,0x0454},{0xBB,0x00bb},
211         {0xBC,0x0458},{0xBD,0x0405},{0xBE,0x0455},{0xBF,0x0457},{0xC0,0x0410},
212         {0xC1,0x0411},{0xC2,0x0412},{0xC3,0x0413},{0xC4,0x0414},{0xC5,0x0415},
213         {0xC6,0x0416},{0xC7,0x0417},{0xC8,0x0418},{0xC9,0x0419},{0xCA,0x041a},
214         {0xCB,0x041b},{0xCC,0x041c},{0xCD,0x041d},{0xCE,0x041e},{0xCF,0x041f},
215         {0xD0,0x0420},{0xD1,0x0421},{0xD2,0x0422},{0xD3,0x0423},{0xD4,0x0424},
216         {0xD5,0x0425},{0xD6,0x0426},{0xD7,0x0427},{0xD8,0x0428},{0xD9,0x0429},
217         {0xDA,0x042a},{0xDB,0x042b},{0xDC,0x042c},{0xDD,0x042d},{0xDE,0x042e},
218         {0xDF,0x042f},{0xE0,0x0430},{0xE1,0x0431},{0xE2,0x0432},{0xE3,0x0433},
219         {0xE4,0x0434},{0xE5,0x0435},{0xE6,0x0436},{0xE7,0x0437},{0xE8,0x0438},
220         {0xE9,0x0439},{0xEA,0x043a},{0xEB,0x043b},{0xEC,0x043c},{0xED,0x043d},
221         {0xEE,0x043e},{0xEF,0x043f},{0xF0,0x0440},{0xF1,0x0441},{0xF2,0x0442},
222         {0xF3,0x0443},{0xF4,0x0444},{0xF5,0x0445},{0xF6,0x0446},{0xF7,0x0447},
223         {0xF8,0x0448},{0xF9,0x0449},{0xFA,0x044a},{0xFB,0x044b},{0xFC,0x044c},
224         {0xFD,0x044d},{0xFE,0x044e},{0xFF,0x044f}
225 };
226
227
228 /* Koi8-r table */
229 typedef struct {
230         UCHAR koi8r;
231         MCHAR unicode;
232 }Koi8rUniTable;
233 const Koi8rUniTable tabKoi8rUni[] = {
234         {0x80,0x2500},{0x81,0x2502},{0x82,0x250C},{0x83,0x2510},{0x84,0x2514},
235         {0x85,0x2518},{0x86,0x251C},{0x87,0x2524},{0x88,0x252C},{0x89,0x2534},
236         {0x8A,0x253C},{0x8B,0x2580},{0x8C,0x2584},{0x8D,0x2588},{0x8E,0x258C},
237         {0x8F,0x2590},{0x90,0x2591},{0x91,0x2592},{0x92,0x2593},{0x93,0x2320},
238         {0x94,0x25A0},{0x95,0x2219},{0x96,0x221A},{0x97,0x2248},{0x98,0x2264},
239         {0x99,0x2265},{0x9A,0x00A0},{0x9B,0x2321},{0x9C,0x00B0},{0x9D,0x00B2},
240         {0x9E,0x00B7},{0x9F,0x00F7},{0xA0,0x2550},{0xA1,0x2551},{0xA2,0x2552},
241         {0xA3,0x0451},{0xA4,0x2553},{0xA5,0x2554},{0xA6,0x2555},{0xA7,0x2556},
242         {0xA8,0x2557},{0xA9,0x2558},{0xAA,0x2559},{0xAB,0x255A},{0xAC,0x255B},
243         {0xAD,0x255C},{0xAE,0x255D},{0xAF,0x255E},{0xB0,0x255F},{0xB1,0x2560},
244         {0xB2,0x2561},{0xB3,0x0401},{0xB4,0x2562},{0xB5,0x2563},{0xB6,0x2564},
245         {0xB7,0x2565},{0xB8,0x2566},{0xB9,0x2567},{0xBA,0x2568},{0xBB,0x2569},
246         {0xBC,0x256A},{0xBD,0x256B},{0xBE,0x256C},{0xBF,0x00A9},{0xC0,0x044E},
247         {0xC1,0x0430},{0xC2,0x0431},{0xC3,0x0446},{0xC4,0x0434},{0xC5,0x0435},
248         {0xC6,0x0444},{0xC7,0x0433},{0xC8,0x0445},{0xC9,0x0438},{0xCA,0x0439},
249         {0xCB,0x043A},{0xCC,0x043B},{0xCD,0x043C},{0xCE,0x043D},{0xCF,0x043E},
250         {0xD0,0x043F},{0xD1,0x044F},{0xD2,0x0440},{0xD3,0x0441},{0xD4,0x0442},
251         {0xD5,0x0443},{0xD6,0x0436},{0xD7,0x0432},{0xD8,0x044C},{0xD9,0x044B},
252         {0xDA,0x0437},{0xDB,0x0448},{0xDC,0x044D},{0xDD,0x0449},{0xDE,0x0447},
253         {0xDF,0x044A},{0xE0,0x042E},{0xE1,0x0410},{0xE2,0x0411},{0xE3,0x0426},
254         {0xE4,0x0414},{0xE5,0x0415},{0xE6,0x0424},{0xE7,0x0413},{0xE8,0x0425},
255         {0xE9,0x0418},{0xEA,0x0419},{0xEB,0x041A},{0xEC,0x041B},{0xED,0x041C},
256         {0xEE,0x041D},{0xEF,0x041E},{0xF0,0x041F},{0xF1,0x042F},{0xF2,0x0420},
257         {0xF3,0x0421},{0xF4,0x0422},{0xF5,0x0423},{0xF6,0x0416},{0xF7,0x0412},
258         {0xF8,0x042C},{0xF9,0x042B},{0xFA,0x0417},{0xFB,0x0428},{0xFC,0x042D},
259         {0xFD,0x0429},{0xFE,0x0427},{0xFF,0x042A}
260 };
261
262
263
264 /* Koi8-u table */
265 typedef struct {
266         UCHAR koi8u;
267         MCHAR unicode;
268 }Koi8uUniTable;
269
270 const Koi8uUniTable tabKoi8uUni[] = {
271         {0x80,0x2500},{0x81,0x2502},{0x82,0x250C},{0x83,0x2510},{0x84,0x2514},
272         {0x85,0x2518},{0x86,0x251C},{0x87,0x2524},{0x88,0x252C},{0x89,0x2534},
273         {0x8A,0x253C},{0x8B,0x2580},{0x8C,0x2584},{0x8D,0x2588},{0x8E,0x258C},
274         {0x8F,0x2590},{0x90,0x2591},{0x91,0x2592},{0x92,0x2593},{0x93,0x2320},
275         {0x94,0x25A0},{0x95,0x2219},{0x96,0x221A},{0x97,0x2248},{0x98,0x2264},
276         {0x99,0x2265},{0x9A,0x00A0},{0x9B,0x2321},{0x9C,0x00B0},{0x9D,0x00B2},
277         {0x9E,0x00B7},{0x9F,0x00F7},{0xA0,0x2550},{0xA1,0x2551},{0xA2,0x2552},
278         {0xA3,0x0451},{0xA4,0x0454},{0xA5,0x2554},{0xA6,0x0456},{0xA7,0x0457},
279         {0xA8,0x2557},{0xA9,0x2558},{0xAA,0x2559},{0xAB,0x255A},{0xAC,0x255B},
280         {0xAD,0x0491},{0xAE,0x255D},{0xAF,0x255E},{0xB0,0x255F},{0xB1,0x2560},
281         {0xB2,0x2561},{0xB3,0x0401},{0xB4,0x0404},{0xB5,0x2563},{0xB6,0x0406},
282         {0xB7,0x0407},{0xB8,0x2566},{0xB9,0x2567},{0xBA,0x2568},{0xBB,0x2569},
283         {0xBC,0x256A},{0xBD,0x0490},{0xBE,0x256C},{0xBF,0x00A9},{0xC0,0x044E},
284         {0xC1,0x0430},{0xC2,0x0431},{0xC3,0x0446},{0xC4,0x0434},{0xC5,0x0435},
285         {0xC6,0x0444},{0xC7,0x0433},{0xC8,0x0445},{0xC9,0x0438},{0xCA,0x0439},
286         {0xCB,0x043A},{0xCC,0x043B},{0xCD,0x043C},{0xCE,0x043D},{0xCF,0x043E},
287         {0xD0,0x043F},{0xD1,0x044F},{0xD2,0x0440},{0xD3,0x0441},{0xD4,0x0442},
288         {0xD5,0x0443},{0xD6,0x0436},{0xD7,0x0432},{0xD8,0x044C},{0xD9,0x044B},
289         {0xDA,0x0437},{0xDB,0x0448},{0xDC,0x044D},{0xDD,0x0449},{0xDE,0x0447},
290         {0xDF,0x044A},{0xE0,0x042E},{0xE1,0x0410},{0xE2,0x0411},{0xE3,0x0426},
291         {0xE4,0x0414},{0xE5,0x0415},{0xE6,0x0424},{0xE7,0x0413},{0xE8,0x0425},
292         {0xE9,0x0418},{0xEA,0x0419},{0xEB,0x041A},{0xEC,0x041B},{0xED,0x041C},
293         {0xEE,0x041D},{0xEF,0x041E},{0xF0,0x041F},{0xF1,0x042F},{0xF2,0x0420},
294         {0xF3,0x0421},{0xF4,0x0422},{0xF5,0x0423},{0xF6,0x0416},{0xF7,0x0412},
295         {0xF8,0x042C},{0xF9,0x042B},{0xFA,0x0417},{0xFB,0x0428},{0xFC,0x042D},
296         {0xFD,0x0429},{0xFE,0x0427},{0xFF,0x042A}
297 };
298
299
300 /* Latin5 table */
301 typedef struct {
302         UCHAR Latin5;
303         MCHAR unicode;
304 }Latin5UniTable;
305
306 const Latin5UniTable tabLatin5Uni[] = {
307         {0xA0,0x00A0},{0xA1,0x0401},{0xA2,0x0402},{0xA3,0x0403},{0xA4,0x0404},
308         {0xA5,0x0405},{0xA6,0x0406},{0xA7,0x0407},{0xA8,0x0408},{0xA9,0x0409},
309         {0xAA,0x040A},{0xAB,0x040B},{0xAC,0x040C},{0xAD,0x00AD},{0xAE,0x040E},
310         {0xAF,0x040F},{0xB0,0x0410},{0xB1,0x0411},{0xB2,0x0412},{0xB3,0x0413},
311         {0xB4,0x0414},{0xB5,0x0415},{0xB6,0x0416},{0xB7,0x0417},{0xB8,0x0418},
312         {0xB9,0x0419},{0xBA,0x041A},{0xBB,0x041B},{0xBC,0x041C},{0xBD,0x041D},
313         {0xBE,0x041E},{0xBF,0x041F},{0xC0,0x0420},{0xC1,0x0421},{0xC2,0x0422},
314         {0xC3,0x0423},{0xC4,0x0424},{0xC5,0x0425},{0xC6,0x0426},{0xC7,0x0427},
315         {0xC8,0x0428},{0xC9,0x0429},{0xCA,0x042A},{0xCB,0x042B},{0xCC,0x042C},
316         {0xCD,0x042D},{0xCE,0x042E},{0xCF,0x042F},{0xD0,0x0430},{0xD1,0x0431},
317         {0xD2,0x0432},{0xD3,0x0433},{0xD4,0x0434},{0xD5,0x0435},{0xD6,0x0436},
318         {0xD7,0x0437},{0xD8,0x0438},{0xD9,0x0439},{0xDA,0x043A},{0xDB,0x043B},
319         {0xDC,0x043C},{0xDD,0x043D},{0xDE,0x043E},{0xDF,0x043F},{0xE0,0x0440},
320         {0xE1,0x0441},{0xE2,0x0442},{0xE3,0x0443},{0xE4,0x0444},{0xE5,0x0445},
321         {0xE6,0x0446},{0xE7,0x0447},{0xE8,0x0448},{0xE9,0x0449},{0xEA,0x044A},
322         {0xEB,0x044B},{0xEC,0x044C},{0xED,0x044D},{0xEE,0x044E},{0xEF,0x044F},
323         {0xF0,0x2116},{0xF1,0x0451},{0xF2,0x0452},{0xF3,0x0453},{0xF4,0x0454},
324         {0xF5,0x0455},{0xF6,0x0456},{0xF7,0x0457},{0xF8,0x0458},{0xF9,0x0459},
325         {0xFA,0x045A},{0xFB,0x045B},{0xFC,0x045C},{0xFD,0x00A7},{0xFE,0x045E},
326         {0xFF,0x045F},
327
328 };
329
330 #define __LOCALCODE_TO_UTF8
331
332 #ifdef __LOCALCODE_TO_UTF8
333
334 bool __WmConvertCodeBufferSizeCheck (char *ftnName, int outBufSize, int requiredBufSize)
335 {
336         if (outBufSize < requiredBufSize) {
337
338                 if (outBufSize == sizeof(void*)) {  // if it is not array
339                         MSG_DEBUG("__WmConvertCodeBufferSizeCheck: Out buffer size seems to be small (%s)\n",ftnName);
340                 } else {
341                         MSG_DEBUG("__WmConvertCodeBufferSizeCheck: Buffer size is too small %s: OutBuffer(%d), RequiredBufSize(%d)\n",ftnName,outBufSize,requiredBufSize);
342                 }
343                 return false;
344         }
345         return true;
346 }
347
348
349
350 MCHAR __WmLngSwapShort(MCHAR aShort)
351 {
352         return ((aShort << 8) + (aShort >> 8));
353 }
354
355 /**
356  * converting byte ordering between Network and device
357  *
358  * @param       mszOutput       [out] converted[destination] MCHAR buffer
359  * @param       mszInput                [in]    source MCHAR buffer
360  * @param       length          [in]    source MCHAR's string length (not byte count)
361  *
362  * @return      This function returns a true on success, or false on failure.
363  */
364 MCHAR* __WmLngSwapPCode(MCHAR *mszOutput, MCHAR *mszInput, int length)
365 {
366         int     i;
367
368         for (i = 0; i < length; i++) {
369                 if (mszInput[i] == (MCHAR)NULL)
370                         break;
371
372                 mszOutput[i] = __WmLngSwapShort(mszInput[i]);
373         }
374
375         mszOutput[i] = NULL;
376
377         return mszOutput;
378 }
379
380
381 /**
382  * This function convert character Processcode(Unicode) to Localcode(UTF8)
383  *
384  * @param       pszOutText      :       Output Buffer Pointer to LocalCode(UTF8)
385  * @param       mszInText       :       Input Buffer Pointer to ProcessCode(UniCode)
386  * @return      This function returns true on success, or false on failure.
387  * @see         WmConvert2LCodeN
388  */
389 bool WmConvert2LCode(char *pszOutText, int outBufSize, MCHAR *mszInText)
390 {
391         int charCount;
392         charCount = WmStrlen(mszInText);
393         if (charCount == 0)
394                 pszOutText[0] = '\0';
395
396         if ((WmConvertPCode2UTF((UCHAR*)pszOutText, outBufSize, mszInText, charCount) == true)) {
397                 return true;
398         } else {
399                 MSG_DEBUG("WmConvert2LCode: Converting Unicode(%x) to utf8 code failed\n",mszInText);
400                 return false;
401         }
402 }
403
404 /**
405  * This function convert character Localcode(UTF8) to Processcode(Unicode)
406  *
407  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
408  * @param       szInText                :       Input Buffer Pointer to LocalCode(UTF8)
409  * @return      This function returns true on success, or false on failure.
410  * @see         WmConvert2PCodeN
411  */
412 bool WmConvert2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
413 {
414         int byteCount;
415
416         byteCount = strlen((char*) szInText);
417
418         if (byteCount == 0)
419                 pmszOutText[0] = NULL;
420
421         if((WmConvertUTF2PCode(pmszOutText, outBufSize,(UCHAR*)szInText, byteCount) == true)) {
422                 return true;
423         } else {
424                 MSG_DEBUG("WmConvert2PCode: Converting UTF8code(%x) to Unicode failed\n",szInText);
425                 return false;
426         }
427 }
428
429 /**
430  * This function convert N'th byte Localcode(UTF8) to Processcode(Unicode)
431  *
432  * @param       pmszOutText             :       Output Buffer Pointer to  ProcessCode(UniCode)
433  * @param       szInText                :       Input Buffer Pointer to LocalCode(KSC5601)
434  * @param       byteCount               :       byte number for converting character
435  * @return      This function returns true on success, or false
436  *                      on failure.
437  * @see         WmConvert2PCode
438  */
439 bool WmConvert2PCodeN(MCHAR *pmszOutText, int outBufSize, char *szInText, int byteCount)
440 {
441         if ((WmConvertUTF2PCode (pmszOutText, outBufSize, (UCHAR*)szInText, byteCount) == true)) {
442                 return true;
443         } else {
444                 MSG_DEBUG("WmConvert2PCodeN: Converting UTF8code(%x) to Unicode failed\n",szInText);
445                 return false;
446         }
447 }
448
449 /**
450  * This function convert N'th character Processcode(Unicode) to Localcode(UTF8)
451  *
452  * @param       pszOutText              :       Output Buffer Pointer to LocalCode(UTF8)
453  * @param       mszInText               :       Input Buffer Pointer to ProcessCode(UniCode)
454  * @param       charCount               :       number for convert n'th chararcter
455  * @return      This function returns true on success, or false on failure.
456  *
457  * @see         WmConvert2LCode
458  */
459 bool WmConvert2LCodeN(char *pszOutText, int outBufSize, MCHAR *mszInText, int charCount)
460 {
461         if ( (WmConvertPCode2UTF((UCHAR*)pszOutText, outBufSize, mszInText, charCount) == true)) {
462                 return true;
463         } else {
464                 MSG_DEBUG("WmConvert2LCodeN: Converting Unicode(%x) to utf8 code failed\n",mszInText);
465                 return false;
466         }
467 }
468
469 /**
470  * This function return output LocalCode Buffer Size
471  *
472  * @param       mszText :       Input ProcessCode String Pointer
473  * @return      This function returns BufferSize for LocalCode
474  *
475  * @see         WmGetPcodeSize
476  */
477 int WmGetLCodeSize(MCHAR *mszText)
478 {
479         int nBuffSize = 0;
480
481         if (mszText[0] == '\0')
482                 return 0;
483
484         while (*mszText != '\0') {
485
486                 if (0x0001 <= *mszText && *mszText <= 0x007F) {
487                         nBuffSize++;
488                         mszText++;
489                 } else if ((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) {
490                         nBuffSize += 2;
491                         mszText++;
492                 } else {
493                         nBuffSize += 3;
494                         mszText++;
495                 }
496         }
497         return nBuffSize;
498 }
499
500
501 /**
502  * This function return output LocalCode Buffer Size
503  *
504  * @param       mszText :       Input ProcessCode String Pointer
505  * @return      This function returns BufferSize for LocalCode
506  *
507  * @see         WmGetPcodeSize
508  */
509 int WmGetLCodeSizeN(MCHAR *mszText, int charCount)
510 {
511         int nBuffSize = 0;
512         int i = 0;
513
514         if (mszText[0] == '\0')
515                 return 0;
516
517         while ((*mszText != '\0') && (i < charCount)) {
518
519                 if (0x0001 <= *mszText && *mszText <= 0x007F) {
520                         nBuffSize++;
521                         mszText++;
522                 } else if ((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) {
523                         nBuffSize += 2;
524                         mszText++;
525                 } else {
526                         nBuffSize += 3;
527                         mszText++;
528                 }
529                 i++;
530         }
531         return nBuffSize;
532 }
533 #endif
534
535
536 /**
537  * This function convert character Localcode(Latin2) to Processcode(Unicode)
538  *
539  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
540  * @param       szInText        :       Input Buffer Pointer to Latin2 code
541  * @return      This function returns true on success, or false
542  *                      on failure.
543  * @see         WmConvert2PCodeN
544  */
545 bool WmConvertLatin2Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
546 {
547         int i = 0;
548         int j = 0;
549         int strLen = 0;
550         bool bInLatin2Table = false;
551
552         strLen = strlen((char *)szInText);
553
554         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
555                 MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
556                 return false;
557         }
558
559         for (i = 0; i < strLen; i++) {
560                 bInLatin2Table = false;
561                 for (j = 0; j < tabLatin2UniMax; j++) {
562                         if ((UCHAR)szInText[i] == tabLatin2Uni[j].latin2) {
563                                 pmszOutText[i] = tabLatin2Uni[j].unicode;
564                                 bInLatin2Table = true;
565                         }
566                 }
567                 if (bInLatin2Table == false)
568                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
569         }
570         /* Latin2 -> UNICODE */
571         pmszOutText[strLen] = NULL;
572
573         return true;
574 }
575
576
577 /**
578  * This function convert character Localcode(Latin3) to Processcode(Unicode)
579  *
580  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
581  * @param       szInText        :       Input Buffer Pointer to Latin2 code
582  * @return      This function returns true on success, or false
583  *                      on failure.
584  * @see         WmConvert2PCodeN
585  */
586 bool WmConvertLatin3Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
587 {
588         int i = 0;
589         int j = 0;
590         int strLen = 0;
591         bool bInLatin3Table = false;
592
593         strLen = strlen((char *)szInText);
594
595         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
596                 MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
597                 return false;
598         }
599
600         for (i = 0; i < strLen; i++) {
601                 bInLatin3Table = false;
602                 for (j = 0; j < tabLatin3UniMax; j++) {
603                         if ((UCHAR)szInText[i] == tabLatin3Uni[j].latin3) {
604                                 pmszOutText[i] = tabLatin3Uni[j].unicode;
605                                 bInLatin3Table = true;
606                         }
607                 }
608                 if (bInLatin3Table == false)
609                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
610         }
611         /* Latin3 -> UNICODE */
612         pmszOutText[strLen] = NULL;
613
614         return true;
615 }
616
617 /**
618  * This function convert character Localcode(Latin4) to Processcode(Unicode)
619  *
620  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
621  * @param       szInText        :       Input Buffer Pointer to Latin2 code
622  * @return      This function returns true on success, or false
623  *                      on failure.
624  * @see         WmConvert2PCodeN
625  */
626 bool WmConvertLatin4Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
627 {
628         int i = 0;
629         int j = 0;
630         int strLen = 0;
631         bool bInLatin4Table = false;
632
633         strLen = strlen((char *)szInText);
634
635         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
636                 MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
637                 return false;
638         }
639
640         for (i = 0; i < strLen; i++) {
641                 bInLatin4Table = false;
642                 for (j = 0; j < tabLatin4UniMax; j++) {
643                         if ((UCHAR)szInText[i] == tabLatin4Uni[j].latin4) {
644                                 pmszOutText[i] = tabLatin4Uni[j].unicode;
645                                 bInLatin4Table = true;
646                         }
647                 }
648                 if (bInLatin4Table == false)
649                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
650         }
651         /* Latin4 -> UNICODE */
652         pmszOutText[strLen] = NULL;
653
654         return true;
655 }
656
657 /**
658  * This function convert character Localcode(Latin8) to Processcode(Unicode)
659  *
660  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
661  * @param       szInText        :       Input Buffer Pointer to Latin2 code
662  * @return      This function returns true on success, or false
663  *                      on failure.
664  * @see         WmConvert2PCodeN
665  */
666 bool WmConvertLatin8Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
667 {
668         int i = 0;
669         int j = 0;
670         int strLen = 0;
671         bool bInLatin8Table = false;
672
673         strLen = strlen((char *)szInText);
674
675         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
676                 MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
677                 return false;
678         }
679
680         for (i = 0; i < strLen; i++) {
681                 bInLatin8Table = false;
682                 for (j = 0; j < tabLatin8UniMax; j++) {
683                         if ((UCHAR)szInText[i] == tabLatin8Uni[j].latin8) {
684                                 pmszOutText[i] = tabLatin8Uni[j].unicode;
685                                 bInLatin8Table = true;
686                         }
687                 }
688                 if (bInLatin8Table == false)
689                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
690         }
691         /* Latin8 -> UNICODE */
692         pmszOutText[strLen] = NULL;
693
694         return true;
695 }
696
697
698 /**
699  * This function convert character Localcode(Win1251) to Processcode(Unicode)
700  *
701  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
702  * @param       szInText        :       Input Buffer Pointer to Win1251 code
703  * @return      This function returns true on success, or false
704  *                      on failure.
705  * @see         WmConvert2PCodeN
706  */
707 bool WmConvertWin1251Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
708 {
709         int i = 0;
710         int j = 0;
711         int strLen = 0;
712         bool bInWin1251Table = false;
713
714         strLen = strlen((char *)szInText);
715
716         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
717                 MSG_DEBUG("WmConvertWin1251Code2PCode: Out buffer size seems to be small!\n");
718                 return false;
719         }
720
721         for (i = 0; i < strLen; i++) {
722                 bInWin1251Table = false;
723                 for (j = 0; j < tabWin1251UniMax; j++) {
724                         if ((UCHAR)szInText[i] == tabWin1251Uni[j].win1251) {
725                                 pmszOutText[i] = tabWin1251Uni[j].unicode;
726                                 bInWin1251Table = true;
727                         }
728                 }
729                 if (bInWin1251Table == false)
730                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
731         }
732         /* Win1251 -> UNICODE */
733         pmszOutText[strLen] = NULL;
734
735         return true;
736 }
737
738
739 /**
740  * This function convert character Localcode(Koi8-r) to Processcode(Unicode)
741  *
742  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
743  * @param       szInText        :       Input Buffer Pointer to Koi8-r code
744  * @return      This function returns true on success, or false
745  *                      on failure.
746  * @see         WmConvert2PCodeN
747  */
748 bool WmConvertKoi8rCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
749 {
750         int i = 0;
751         int j = 0;
752         int strLen = 0;
753         bool bInKoi8rTable = false;
754
755         strLen = strlen((char *)szInText);
756
757         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
758                 MSG_DEBUG("WmConvertKoi8rCode2PCode: Out buffer size seems to be small!\n");
759                 return false;
760         }
761
762         for (i = 0; i < strLen; i++) {
763                 bInKoi8rTable = false;
764                 for (j = 0; j < tabKoi8rUniMax; j++) {
765                         if ((UCHAR)szInText[i] == tabKoi8rUni[j].koi8r) {
766                                 pmszOutText[i] = tabKoi8rUni[j].unicode;
767                                 bInKoi8rTable = true;
768                         }
769                 }
770                 if (bInKoi8rTable == false)
771                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
772         }
773         /* bInKoi8-rTable -> UNICODE */
774         pmszOutText[strLen] = NULL;
775
776         return true;
777 }
778
779
780 /**
781  * This function convert character Localcode(Koi8-u) to Processcode(Unicode)
782  *
783  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
784  * @param       szInText        :       Input Buffer Pointer to Koi8-u code
785  * @return      This function returns true on success, or false
786  *                      on failure.
787  * @see         WmConvert2PCodeN
788  */
789 bool WmConvertKoi8uCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
790 {
791         int i = 0;
792         int j = 0;
793         int strLen = 0;
794         bool bInKoi8uTable = false;
795
796         strLen = strlen((char *)szInText);
797
798         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
799                 MSG_DEBUG("WmConvertKoi8uCode2PCode: Out buffer size seems to be small!\n");
800                 return false;
801         }
802
803         for (i = 0; i < strLen; i++) {
804                 bInKoi8uTable = false;
805                 for (j = 0; j < tabKoi8uUniMax; j++) {
806                         if ((UCHAR)szInText[i] == tabKoi8uUni[j].koi8u) {
807                                 pmszOutText[i] = tabKoi8uUni[j].unicode;
808                                 bInKoi8uTable = true;
809                         }
810                 }
811                 if (bInKoi8uTable == false)
812                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
813         }
814         /* bInKoi8uTable -> UNICODE */
815         pmszOutText[strLen] = NULL;
816
817         return true;
818 }
819
820
821 /**
822  * This function convert character Localcode(Latin15) to Processcode(Unicode)
823  *
824  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
825  * @param       szInText        :       Input Buffer Pointer to Latin2 code
826  * @return      This function returns true on success, or false
827  *                      on failure.
828  * @see         WmConvert2PCodeN
829  */
830 bool WmConvertLatin15Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
831 {
832         int i = 0;
833         int j = 0;
834         int strLen = 0;
835         bool bInLatin15Table = false;
836
837         strLen = strlen((char *)szInText);
838
839         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
840                 MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
841                 return false;
842         }
843
844         for (i = 0; i < strLen; i++) {
845                 bInLatin15Table = false;
846                 for (j = 0; j < tabLatin15UniMax; j++) {
847                         if ((UCHAR)szInText[i] == tabLatin15Uni[j].latin15) {
848                                 pmszOutText[i] = tabLatin15Uni[j].unicode;
849                                 bInLatin15Table = true;
850                         }
851                 }
852                 if (bInLatin15Table == false)
853                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
854         }
855         /* Latin15 -> UNICODE */
856         pmszOutText[strLen] = NULL;
857
858         return true;
859 }
860
861
862
863
864 /**
865  * This function convert character Localcode(Latin5) to Processcode(Unicode)
866  *
867  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
868  * @param       szInText        :       Input Buffer Pointer to Latin5 code
869  * @return      This function returns true on success, or false
870  *                      on failure.
871  * @see         WmConvert2PCodeN
872  */
873 bool WmConvertLatin5Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
874 {
875         int i = 0;
876         int j = 0;
877         int strLen = 0;
878         bool bInLatin5Table = false;
879
880         strLen = strlen((char *)szInText);
881
882         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
883                 MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
884                 return false;
885         }
886
887         for (i = 0; i < strLen; i++) {
888                 bInLatin5Table = false;
889                 for (j = 0; j < tabLatin5UniMax; j++) {
890                         if ((UCHAR)szInText[i] == tabLatin5Uni[j].Latin5) {
891                                 pmszOutText[i] = tabLatin5Uni[j].unicode;
892                                 bInLatin5Table = true;
893                         }
894                 }
895                 if (bInLatin5Table == false)
896                         pmszOutText[i] = (MCHAR)(UCHAR)szInText[i];
897         }
898         /* Latin5 -> UNICODE */
899         pmszOutText[strLen] = NULL;
900
901         return true;
902 }
903
904
905 int WmGetLatin32UTFCodeSize(unsigned char *szSrc, int nChar)
906 {
907         int bufferSize = 0;
908         int latin3Size = -1;
909         MCHAR *pmszText;
910
911         bufferSize = nChar*3+1;
912         pmszText = (MCHAR *)malloc(bufferSize);
913         if (!pmszText) {
914                 MSG_DEBUG("WmGetLatin32UTFCodeSize: memory allocation is failed!\n");
915                 return -1;
916         }
917         WmConvertLatin3Code2PCode(pmszText, bufferSize, (char*)szSrc);
918         latin3Size = WmGetLCodeSize(pmszText);
919         free(pmszText);
920         return latin3Size;
921 }
922
923
924 int WmGetLatin42UTFCodeSize(unsigned char *szSrc, int nChar)
925 {
926         int bufferSize = 0;
927         int latin4Size = -1;
928         MCHAR *pmszText;
929
930         bufferSize = nChar*3+1;
931         pmszText = (MCHAR *)malloc(bufferSize);
932         if (!pmszText) {
933                 MSG_DEBUG("WmGetLatin42UTFCodeSize: memory allocation is failed!\n");
934                 return -1;
935         }
936         WmConvertLatin4Code2PCode(pmszText, bufferSize, (char*)szSrc);
937         latin4Size = WmGetLCodeSize(pmszText);
938         free(pmszText);
939         return latin4Size;
940 }
941
942
943 int WmGetLatin82UTFCodeSize(unsigned char *szSrc, int nChar)
944 {
945         int bufferSize = 0;
946         int latin8Size = -1;
947         MCHAR *pmszText;
948
949         bufferSize = nChar*3+1;
950         pmszText = (MCHAR *)malloc(bufferSize);
951         if (!pmszText) {
952                 MSG_DEBUG("WmGetLatin82UTFCodeSize: memory allocation is failed!\n");
953                 return -1;
954         }
955         WmConvertLatin8Code2PCode(pmszText, bufferSize, (char*)szSrc);
956         latin8Size = WmGetLCodeSize(pmszText);
957         free(pmszText);
958         return latin8Size;
959 }
960
961 int WmGetLatin152UTFCodeSize(unsigned char *szSrc, int nChar)
962 {
963         int bufferSize = 0;
964         int latin15Size = -1;
965         MCHAR *pmszText;
966
967         bufferSize = nChar*3+1;
968         pmszText = (MCHAR *)malloc(bufferSize);
969         if (!pmszText) {
970                 MSG_DEBUG("WmGetLatin152UTFCodeSize: memory allocation is failed!\n");
971                 return -1;
972         }
973         WmConvertLatin15Code2PCode(pmszText, bufferSize, (char*)szSrc);
974         latin15Size = WmGetLCodeSize(pmszText);
975         free(pmszText);
976         return latin15Size;
977 }
978
979 int WmGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
980 {
981         int bufferSize = 0;
982         int latin5Size = -1;
983         MCHAR *pmszText;
984
985         bufferSize = nChar*3+1;
986         pmszText = (MCHAR *)malloc(bufferSize);
987         if (!pmszText) {
988                 MSG_DEBUG("WmGetLatin52UTFCodeSize: memory allocation is failed!\n");
989                 return -1;
990         }
991         WmConvertLatin5Code2PCode(pmszText, bufferSize, (char*)szSrc);
992         latin5Size = WmGetLCodeSize(pmszText);
993         free(pmszText);
994         return latin5Size;
995 }
996
997
998 /**
999  * This function convert character Localcode(Latin1) to Processcode(Unicode)
1000  *
1001  * @param       pmszOutText             :       Output Buffer Pointer to ProcessCode(UniCode)
1002  * @param       szInText        :       Input Buffer Pointer to LocalCode(KSC5601)
1003  * @return      This function returns true on success, or false
1004  *                      on failure.
1005  * @see         WmConvert2PCodeN
1006  */
1007 bool WmConvertLatinCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText)
1008 {
1009         UINT strLen;
1010
1011         strLen = strlen((char *)szInText);
1012
1013         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) {
1014                 MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n");
1015                 return false;
1016         }
1017
1018         /* Latin1 -> UNICODE */
1019         __WmLngConvertLatin12Unicode(pmszOutText,(UCHAR*)szInText,strLen);
1020         pmszOutText[strLen] = NULL;
1021
1022         return true;
1023 }
1024
1025 /**
1026  * This function convert N'th character Localcode(Latin1) to Processcode(Unicode)
1027  *
1028  * @param       pmszOutText             :       Output Buffer Pointer to  ProcessCode(UniCode)
1029  * @param       szInText        :       Input Buffer Pointer to LocalCode(KSC5601)
1030  * @param       charCount               :       number for convert n'th chararcter
1031  * @return      This function returns true on success, or false
1032  *                      on failure.
1033  * @see         WmConvert2PCode
1034  */
1035 bool WmConvertLatinCode2PCodeN(MCHAR *pmszOutText, int outBufSize, char *szInText, int charCount)
1036 {
1037         int strLen;
1038
1039         if (charCount == 0) {
1040                 MSG_DEBUG("WmConvert2PCodeN: charCount is0\n");
1041                 pmszOutText[charCount] = NULL;
1042         }
1043
1044         if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, charCount) == false) {
1045                 MSG_DEBUG("WmConvertLatinCode2PCodeN: Out buffer size seems to be small!\n");
1046                 return false;
1047         }
1048
1049         /* Latin1 -> UNICODE */
1050         __WmLngLatin12UnicodeN (pmszOutText, (UCHAR*)szInText, charCount);
1051
1052         strLen = strlen((char *)szInText);
1053         if(strLen < charCount) {
1054                 pmszOutText[strLen] = NULL;
1055         } else {
1056                 pmszOutText[charCount] = NULL;
1057         }
1058
1059         return true;
1060 }
1061
1062 /*
1063  * This function convert character Processcode(Unicode) to Localcode(Latin1)
1064  *
1065  * @param       pOutStr         :       Output Buffer Pointer to LocalCode(Latin1)
1066  * @param       pInputStr       :       Input Buffer Pointer to ProcessCode(UniCode)
1067  * @param       len                     :       number for convert n'th chararcter
1068  * @return      void
1069  *
1070  * @see
1071  */
1072 static void __WmLngReverseKeyCode(UCHAR *pOutStr, MCHAR *pInputStr, UINT len)
1073 {
1074         UCHAR *rear=NULL;
1075         MCHAR *p;
1076         UCHAR temp;
1077
1078         rear = pOutStr;
1079
1080         for (p = pInputStr; len > 0 && p; len--) {
1081                 if (*pInputStr < MAX_ASCII_NUM) {                  // ASCII String
1082                         if (*p == 0)
1083                                 *rear = '\0';
1084                         temp = (UCHAR)(*p);
1085                         *rear = temp;
1086                         rear++;
1087                         p++;
1088                         if(len == 1)
1089                                 *rear = '\0';
1090                 } else {
1091                         *rear = 0x3F;
1092                         rear++;
1093                         p++;
1094                         if(len == 1)
1095                                 *rear = '\0';
1096                 }
1097                 pInputStr = p;
1098         }
1099 }
1100
1101
1102 /*
1103  * This function convert character Localcode(Latin1) to Processcode(Unicode)
1104  *
1105  * @param       des[in]         :       Output Buffer Pointer to ProcessCode(UniCode)
1106  * @param       str[in]         :       Input Buffer Pointer to LocalCode(Latin1)
1107  * @param       len[in]         :       number for convert n'th chararcter
1108  * @return      This function returns number for convert n'th chararcter on success
1109  *
1110  * @see
1111  */
1112 static int __WmLngConvertLatin12Unicode (MCHAR *des, UCHAR *str, UINT len)
1113 {
1114         MCHAR *org;
1115         org = des;
1116         while (len>0) {
1117                 *des++ = *str++;
1118                 len--;
1119         }
1120
1121         return (des - org) ;
1122 }
1123
1124 /*
1125  * This function convert N'th character Localcode(Latin1) to Processcode(Unicode)
1126  *
1127  * @param       pOutStr         :       Output Buffer Pointer to  ProcessCode(UniCode)
1128  * @param       pInputStr       :       Input Buffer Pointer to LocalCode(Latin1)
1129  * @param       len                     :       number for convert n'th chararcter
1130  * @return      This function returns true on success, or false on failure.
1131  *
1132  * @see
1133  */
1134 static UINT __WmLngLatin12UnicodeN(MCHAR *pOutStr, UCHAR *pInputStr, UINT len)
1135 {
1136         UINT n;
1137
1138         n = strlen((char*)pInputStr);
1139
1140         if(len > n)
1141                 len = n;
1142
1143         return __WmLngConvertLatin12Unicode (pOutStr, pInputStr, len);
1144 }
1145