1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | #include "sal/config.h" |
30 | |
31 | #include <cstddef> |
32 | #include <cstring> |
33 | |
34 | #include "rtl/tencinfo.h" |
35 | |
36 | #include "gettextencodingdata.hxx" |
37 | #include "tenchelp.hxx" |
38 | |
39 | sal_Bool SAL_CALL rtl_isOctetTextEncoding(rtl_TextEncoding nEncoding) |
40 | { |
41 | return |
42 | nEncoding > RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) |
43 | && nEncoding != 9 |
44 | && nEncoding <= RTL_TEXTENCODING_ADOBE_DINGBATS(((rtl_TextEncoding) 94)); |
45 | } |
46 | |
47 | |
48 | |
49 | static void Impl_toAsciiLower( const char* pName, char* pBuf ) |
50 | { |
51 | while ( *pName ) |
52 | { |
53 | |
54 | if ( (*pName >= 0x41) && (*pName <= 0x5A) ) |
55 | *pBuf = (*pName)+0x20; |
56 | else |
57 | *pBuf = *pName; |
58 | |
59 | pBuf++; |
60 | pName++; |
61 | } |
62 | |
63 | *pBuf = '\0'; |
64 | } |
65 | |
66 | |
67 | |
68 | static void Impl_toAsciiLowerAndRemoveNonAlphanumeric( const char* pName, char* pBuf ) |
69 | { |
70 | while ( *pName ) |
71 | { |
72 | |
73 | if ( (*pName >= 0x41) && (*pName <= 0x5A) ) |
74 | { |
75 | *pBuf = (*pName)+0x20; |
76 | pBuf++; |
77 | } |
78 | |
79 | else if ( ((*pName >= 0x61) && (*pName <= 0x7A)) || |
80 | ((*pName >= 0x30) && (*pName <= 0x39)) ) |
81 | { |
82 | *pBuf = *pName; |
83 | pBuf++; |
84 | } |
85 | |
86 | pName++; |
87 | } |
88 | |
89 | *pBuf = '\0'; |
90 | } |
91 | |
92 | |
93 | |
94 | |
95 | static bool Impl_matchString( const char* pCompStr, const char* pMatchStr ) |
96 | { |
97 | |
98 | |
99 | while ( *pMatchStr ) |
100 | { |
101 | if ( *pCompStr != *pMatchStr ) |
102 | return false; |
103 | |
104 | pCompStr++; |
105 | pMatchStr++; |
106 | } |
107 | |
108 | return true; |
109 | } |
110 | |
111 | |
112 | |
113 | struct ImplStrCharsetDef |
114 | { |
115 | const char* mpCharsetStr; |
116 | rtl_TextEncoding meTextEncoding; |
117 | }; |
118 | |
119 | struct ImplStrFirstPartCharsetDef |
120 | { |
121 | const char* mpCharsetStr; |
122 | const ImplStrCharsetDef* mpSecondPartTab; |
123 | }; |
124 | |
125 | |
126 | |
127 | sal_Bool SAL_CALL rtl_getTextEncodingInfo( rtl_TextEncoding eTextEncoding, rtl_TextEncodingInfo* pEncInfo ) |
128 | { |
129 | const ImplTextEncodingData* pData; |
130 | |
131 | pData = Impl_getTextEncodingData( eTextEncoding ); |
132 | if ( !pData ) |
133 | { |
134 | |
135 | |
136 | if ( pEncInfo->StructSize < 5 ) |
137 | return false; |
138 | pEncInfo->MinimumCharSize = 1; |
139 | |
140 | if ( pEncInfo->StructSize < 6 ) |
141 | return true; |
142 | pEncInfo->MaximumCharSize = 1; |
143 | |
144 | if ( pEncInfo->StructSize < 7 ) |
145 | return true; |
146 | pEncInfo->AverageCharSize = 1; |
147 | |
148 | if ( pEncInfo->StructSize < 12 ) |
149 | return true; |
150 | pEncInfo->Flags = 0; |
151 | |
152 | return false; |
153 | } |
154 | |
155 | if ( pEncInfo->StructSize < 5 ) |
156 | return false; |
157 | pEncInfo->MinimumCharSize = pData->mnMinCharSize; |
158 | |
159 | if ( pEncInfo->StructSize < 6 ) |
160 | return true; |
161 | pEncInfo->MaximumCharSize = pData->mnMaxCharSize; |
162 | |
163 | if ( pEncInfo->StructSize < 7 ) |
164 | return true; |
165 | pEncInfo->AverageCharSize = pData->mnAveCharSize; |
166 | |
167 | if ( pEncInfo->StructSize < 12 ) |
168 | return true; |
169 | pEncInfo->Flags = pData->mnInfoFlags; |
170 | |
171 | return true; |
172 | } |
173 | |
174 | |
175 | |
176 | rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromWindowsCharset( sal_uInt8 nWinCharset ) |
177 | { |
178 | rtl_TextEncoding eTextEncoding; |
179 | |
180 | switch ( nWinCharset ) |
181 | { |
182 | case 0: eTextEncoding = RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)); break; |
183 | case 2: eTextEncoding = RTL_TEXTENCODING_SYMBOL(((rtl_TextEncoding) 10)); break; |
184 | case 77: eTextEncoding = RTL_TEXTENCODING_APPLE_ROMAN(((rtl_TextEncoding) 2)); break; |
185 | case 128: eTextEncoding = RTL_TEXTENCODING_MS_932(((rtl_TextEncoding) 60)); break; |
186 | case 129: eTextEncoding = RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)); break; |
187 | case 130: eTextEncoding = RTL_TEXTENCODING_MS_1361(((rtl_TextEncoding) 84)); break; |
188 | case 134: eTextEncoding = RTL_TEXTENCODING_MS_936(((rtl_TextEncoding) 61)); break; |
189 | case 136: eTextEncoding = RTL_TEXTENCODING_MS_950(((rtl_TextEncoding) 63)); break; |
190 | case 161: eTextEncoding = RTL_TEXTENCODING_MS_1253(((rtl_TextEncoding) 35)); break; |
191 | case 162: eTextEncoding = RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)); break; |
192 | case 163: eTextEncoding = RTL_TEXTENCODING_MS_1258(((rtl_TextEncoding) 40)); break; |
193 | case 177: eTextEncoding = RTL_TEXTENCODING_MS_1255(((rtl_TextEncoding) 37)); break; |
194 | case 178: eTextEncoding = RTL_TEXTENCODING_MS_1256(((rtl_TextEncoding) 38)); break; |
195 | case 186: eTextEncoding = RTL_TEXTENCODING_MS_1257(((rtl_TextEncoding) 39)); break; |
196 | case 204: eTextEncoding = RTL_TEXTENCODING_MS_1251(((rtl_TextEncoding) 34)); break; |
197 | case 222: eTextEncoding = RTL_TEXTENCODING_MS_874(((rtl_TextEncoding) 32)); break; |
198 | case 238: eTextEncoding = RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)); break; |
199 | case 255: eTextEncoding = RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)); break; |
200 | default: eTextEncoding = RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)); break; |
201 | }; |
202 | |
203 | return eTextEncoding; |
204 | } |
205 | |
206 | |
207 | |
208 | rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const char* pUnixCharset ) |
209 | { |
210 | |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | static ImplStrCharsetDef const aUnixCharsetISOTab[] = |
219 | { |
220 | { "15", RTL_TEXTENCODING_ISO_8859_15(((rtl_TextEncoding) 22)) }, |
221 | { "14", RTL_TEXTENCODING_ISO_8859_14(((rtl_TextEncoding) 21)) }, |
222 | { "13", RTL_TEXTENCODING_ISO_8859_13(((rtl_TextEncoding) 78)) }, |
223 | { "11", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
224 | { "10", RTL_TEXTENCODING_ISO_8859_10(((rtl_TextEncoding) 77)) }, |
225 | { "1", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
226 | { "2", RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)) }, |
227 | { "3", RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)) }, |
228 | { "4", RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)) }, |
229 | { "5", RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)) }, |
230 | { "6", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
231 | { "7", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
232 | { "8", RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)) }, |
233 | { "9", RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)) }, |
234 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
235 | }; |
236 | |
237 | static ImplStrCharsetDef const aUnixCharsetADOBETab[] = |
238 | { |
239 | { "fontspecific", RTL_TEXTENCODING_SYMBOL(((rtl_TextEncoding) 10)) }, |
240 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
241 | }; |
242 | |
243 | static ImplStrCharsetDef const aUnixCharsetMSTab[] = |
244 | { |
245 | { "1252", RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)) }, |
246 | { "1250", RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)) }, |
247 | { "1251", RTL_TEXTENCODING_MS_1251(((rtl_TextEncoding) 34)) }, |
248 | { "1253", RTL_TEXTENCODING_MS_1253(((rtl_TextEncoding) 35)) }, |
249 | { "1254", RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)) }, |
250 | { "1255", RTL_TEXTENCODING_MS_1255(((rtl_TextEncoding) 37)) }, |
251 | { "1256", RTL_TEXTENCODING_MS_1256(((rtl_TextEncoding) 38)) }, |
252 | { "1257", RTL_TEXTENCODING_MS_1257(((rtl_TextEncoding) 39)) }, |
253 | { "1258", RTL_TEXTENCODING_MS_1258(((rtl_TextEncoding) 40)) }, |
254 | { "932", RTL_TEXTENCODING_MS_932(((rtl_TextEncoding) 60)) }, |
255 | { "936", RTL_TEXTENCODING_MS_936(((rtl_TextEncoding) 61)) }, |
256 | { "949", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
257 | { "950", RTL_TEXTENCODING_MS_950(((rtl_TextEncoding) 63)) }, |
258 | { "1361", RTL_TEXTENCODING_MS_1361(((rtl_TextEncoding) 84)) }, |
259 | { "cp1252", RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)) }, |
260 | { "cp1250", RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)) }, |
261 | { "cp1251", RTL_TEXTENCODING_MS_1251(((rtl_TextEncoding) 34)) }, |
262 | { "cp1253", RTL_TEXTENCODING_MS_1253(((rtl_TextEncoding) 35)) }, |
263 | { "cp1254", RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)) }, |
264 | { "cp1255", RTL_TEXTENCODING_MS_1255(((rtl_TextEncoding) 37)) }, |
265 | { "cp1256", RTL_TEXTENCODING_MS_1256(((rtl_TextEncoding) 38)) }, |
266 | { "cp1257", RTL_TEXTENCODING_MS_1257(((rtl_TextEncoding) 39)) }, |
267 | { "cp1258", RTL_TEXTENCODING_MS_1258(((rtl_TextEncoding) 40)) }, |
268 | { "cp932", RTL_TEXTENCODING_MS_932(((rtl_TextEncoding) 60)) }, |
269 | { "cp936", RTL_TEXTENCODING_MS_936(((rtl_TextEncoding) 61)) }, |
270 | { "cp949", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
271 | { "cp950", RTL_TEXTENCODING_MS_950(((rtl_TextEncoding) 63)) }, |
272 | { "cp1361", RTL_TEXTENCODING_MS_1361(((rtl_TextEncoding) 84)) }, |
273 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
274 | }; |
275 | |
276 | static ImplStrCharsetDef const aUnixCharsetIBMTab[] = |
277 | { |
278 | { "437", RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)) }, |
279 | { "850", RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)) }, |
280 | { "860", RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)) }, |
281 | { "861", RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)) }, |
282 | { "863", RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)) }, |
283 | { "865", RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)) }, |
284 | { "737", RTL_TEXTENCODING_IBM_737(((rtl_TextEncoding) 23)) }, |
285 | { "775", RTL_TEXTENCODING_IBM_775(((rtl_TextEncoding) 24)) }, |
286 | { "852", RTL_TEXTENCODING_IBM_852(((rtl_TextEncoding) 25)) }, |
287 | { "855", RTL_TEXTENCODING_IBM_855(((rtl_TextEncoding) 26)) }, |
288 | { "857", RTL_TEXTENCODING_IBM_857(((rtl_TextEncoding) 27)) }, |
289 | { "862", RTL_TEXTENCODING_IBM_862(((rtl_TextEncoding) 28)) }, |
290 | { "864", RTL_TEXTENCODING_IBM_864(((rtl_TextEncoding) 29)) }, |
291 | { "866", RTL_TEXTENCODING_IBM_866(((rtl_TextEncoding) 30)) }, |
292 | { "869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
293 | { "874", RTL_TEXTENCODING_MS_874(((rtl_TextEncoding) 32)) }, |
294 | { "1004", RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)) }, |
295 | { "65400", RTL_TEXTENCODING_SYMBOL(((rtl_TextEncoding) 10)) }, |
296 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
297 | }; |
298 | |
299 | static ImplStrCharsetDef const aUnixCharsetKOI8Tab[] = |
300 | { |
301 | { "r", RTL_TEXTENCODING_KOI8_R(((rtl_TextEncoding) 74)) }, |
302 | { "u", RTL_TEXTENCODING_KOI8_U(((rtl_TextEncoding) 88)) }, |
303 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
304 | }; |
305 | |
306 | static ImplStrCharsetDef aUnixCharsetJISX0208Tab[] = |
307 | { |
308 | { NULL__null, RTL_TEXTENCODING_JIS_X_0208(((rtl_TextEncoding) 82)) } |
309 | }; |
310 | |
311 | static ImplStrCharsetDef aUnixCharsetJISX0201Tab[] = |
312 | { |
313 | { NULL__null, RTL_TEXTENCODING_JIS_X_0201(((rtl_TextEncoding) 81)) } |
314 | }; |
315 | |
316 | static ImplStrCharsetDef aUnixCharsetJISX0212Tab[] = |
317 | { |
318 | { NULL__null, RTL_TEXTENCODING_JIS_X_0212(((rtl_TextEncoding) 83)) } |
319 | }; |
320 | |
321 | static ImplStrCharsetDef aUnixCharsetGBTab[] = |
322 | { |
323 | { NULL__null, RTL_TEXTENCODING_GB_2312(((rtl_TextEncoding) 65)) } |
324 | }; |
325 | |
326 | static ImplStrCharsetDef aUnixCharsetGBKTab[] = |
327 | { |
328 | { NULL__null, RTL_TEXTENCODING_GBK(((rtl_TextEncoding) 67)) } |
329 | }; |
330 | |
331 | static ImplStrCharsetDef aUnixCharsetBIG5Tab[] = |
332 | { |
333 | { NULL__null, RTL_TEXTENCODING_BIG5(((rtl_TextEncoding) 68)) } |
334 | }; |
335 | |
336 | static ImplStrCharsetDef const aUnixCharsetKSC56011987Tab[] = |
337 | { |
338 | { NULL__null, RTL_TEXTENCODING_EUC_KR(((rtl_TextEncoding) 79)) } |
339 | }; |
340 | |
341 | static ImplStrCharsetDef const aUnixCharsetKSC56011992Tab[] = |
342 | { |
343 | { NULL__null, RTL_TEXTENCODING_MS_1361(((rtl_TextEncoding) 84)) } |
344 | }; |
345 | |
346 | static ImplStrCharsetDef const aUnixCharsetISO10646Tab[] = |
347 | { |
348 | { NULL__null, RTL_TEXTENCODING_UNICODE(((rtl_TextEncoding) 0xFFFF)) } |
349 | }; |
350 | |
351 | static ImplStrCharsetDef const aUnixCharsetUNICODETab[] = |
352 | { |
353 | |
354 | |
355 | { NULL__null, RTL_TEXTENCODING_UNICODE(((rtl_TextEncoding) 0xFFFF)) } |
356 | }; |
357 | |
358 | static ImplStrCharsetDef const aUnixCharsetSymbolTab[] = |
359 | { |
360 | { NULL__null, RTL_TEXTENCODING_SYMBOL(((rtl_TextEncoding) 10)) } |
361 | }; |
362 | |
363 | |
364 | |
365 | static ImplStrCharsetDef const aUnixCharsetTIS620Tab[] = |
366 | { |
367 | { "0", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
368 | { "2529", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
369 | { "2533", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
370 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
371 | }; |
372 | static ImplStrCharsetDef const aUnixCharsetTIS6202529Tab[] = |
373 | { |
374 | { "1", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
375 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
376 | }; |
377 | static ImplStrCharsetDef const aUnixCharsetTIS6202533Tab[] = |
378 | { |
379 | { "0", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
380 | { "1", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
381 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
382 | }; |
383 | |
384 | static ImplStrFirstPartCharsetDef const aUnixCharsetFirstPartTab[] = |
385 | { |
386 | { "iso8859", aUnixCharsetISOTab }, |
387 | { "adobe", aUnixCharsetADOBETab }, |
388 | { "ansi", aUnixCharsetMSTab }, |
389 | { "microsoft", aUnixCharsetMSTab }, |
390 | { "ibm", aUnixCharsetIBMTab }, |
391 | { "koi8", aUnixCharsetKOI8Tab }, |
392 | { "jisx0208", aUnixCharsetJISX0208Tab }, |
393 | { "jisx0208.1983", aUnixCharsetJISX0208Tab }, |
394 | { "jisx0201", aUnixCharsetJISX0201Tab }, |
395 | { "jisx0201.1976", aUnixCharsetJISX0201Tab }, |
396 | { "jisx0212", aUnixCharsetJISX0212Tab }, |
397 | { "jisx0212.1990", aUnixCharsetJISX0212Tab }, |
398 | { "gb2312", aUnixCharsetGBTab }, |
399 | { "gbk", aUnixCharsetGBKTab }, |
400 | { "big5", aUnixCharsetBIG5Tab }, |
401 | { "iso10646", aUnixCharsetISO10646Tab }, |
402 | |
403 | { "sunolcursor", aUnixCharsetSymbolTab }, |
404 | { "sunolglyph", aUnixCharsetSymbolTab }, |
405 | { "iso10646", aUnixCharsetUNICODETab }, |
406 | { "ksc5601.1987", aUnixCharsetKSC56011987Tab }, |
407 | { "ksc5601.1992", aUnixCharsetKSC56011992Tab }, |
408 | { "tis620.2529", aUnixCharsetTIS6202529Tab }, |
409 | { "tis620.2533", aUnixCharsetTIS6202533Tab }, |
410 | { "tis620", aUnixCharsetTIS620Tab }, |
411 | |
412 | |
413 | |
414 | |
415 | { NULL__null, NULL__null } |
416 | }; |
417 | |
418 | rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)); |
419 | char* pBuf; |
420 | char* pTempBuf; |
421 | sal_uInt32 nBufLen = strlen( pUnixCharset )+1; |
422 | const char* pFirstPart; |
423 | const char* pSecondPart; |
424 | |
425 | |
426 | pBuf = new char[nBufLen]; |
427 | Impl_toAsciiLower( pUnixCharset, pBuf ); |
428 | |
429 | |
430 | pFirstPart = pBuf; |
431 | pSecondPart = NULL__null; |
432 | pTempBuf = pBuf; |
433 | while ( *pTempBuf ) |
434 | { |
435 | if ( *pTempBuf == '-' ) |
436 | { |
437 | *pTempBuf = '\0'; |
438 | pSecondPart = pTempBuf+1; |
439 | break; |
440 | } |
441 | |
442 | pTempBuf++; |
443 | } |
444 | |
445 | |
446 | if ( pSecondPart ) |
447 | { |
448 | |
449 | const ImplStrFirstPartCharsetDef* pFirstPartData = aUnixCharsetFirstPartTab; |
450 | while ( pFirstPartData->mpCharsetStr ) |
451 | { |
452 | if ( Impl_matchString( pFirstPart, pFirstPartData->mpCharsetStr ) ) |
453 | { |
454 | |
455 | const ImplStrCharsetDef* pData = pFirstPartData->mpSecondPartTab; |
456 | while ( pData->mpCharsetStr ) |
457 | { |
458 | if ( Impl_matchString( pSecondPart, pData->mpCharsetStr ) ) |
459 | { |
460 | eEncoding = pData->meTextEncoding; |
| Value stored to 'eEncoding' is never read |
461 | break; |
462 | } |
463 | |
464 | pData++; |
465 | } |
466 | |
467 | |
468 | eEncoding = pData->meTextEncoding; |
469 | break; |
470 | } |
471 | |
472 | pFirstPartData++; |
473 | } |
474 | } |
475 | |
476 | delete[] pBuf; |
477 | |
478 | return eEncoding; |
479 | } |
480 | |
481 | |
482 | |
483 | rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeCharset ) |
484 | { |
485 | |
486 | |
487 | |
488 | |
489 | static ImplStrCharsetDef const aVIPMimeCharsetTab[] = |
490 | { |
491 | { "usascii", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
492 | { "utf8", RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) }, |
493 | { "utf7", RTL_TEXTENCODING_UTF7(((rtl_TextEncoding) 75)) }, |
494 | { "iso88591", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
495 | { "iso88592", RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)) }, |
496 | { "iso88593", RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)) }, |
497 | { "iso88594", RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)) }, |
498 | { "iso88595", RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)) }, |
499 | { "iso88596", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
500 | { "iso88597", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
501 | { "iso88598", RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)) }, |
502 | { "iso88599", RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)) }, |
503 | { "iso885910", RTL_TEXTENCODING_ISO_8859_10(((rtl_TextEncoding) 77)) }, |
504 | { "iso885913", RTL_TEXTENCODING_ISO_8859_13(((rtl_TextEncoding) 78)) }, |
505 | { "iso885914", RTL_TEXTENCODING_ISO_8859_14(((rtl_TextEncoding) 21)) }, |
506 | { "iso885915", RTL_TEXTENCODING_ISO_8859_15(((rtl_TextEncoding) 22)) }, |
507 | { "iso2022jp", RTL_TEXTENCODING_ISO_2022_JP(((rtl_TextEncoding) 72)) }, |
508 | { "iso2022jp2", RTL_TEXTENCODING_ISO_2022_JP(((rtl_TextEncoding) 72)) }, |
509 | { "iso2022cn", RTL_TEXTENCODING_ISO_2022_CN(((rtl_TextEncoding) 73)) }, |
510 | { "iso2022cnext", RTL_TEXTENCODING_ISO_2022_CN(((rtl_TextEncoding) 73)) }, |
511 | { "iso2022kr", RTL_TEXTENCODING_ISO_2022_KR(((rtl_TextEncoding) 80)) }, |
512 | { "eucjp", RTL_TEXTENCODING_EUC_JP(((rtl_TextEncoding) 69)) }, |
513 | { "shiftjis", RTL_TEXTENCODING_SHIFT_JIS(((rtl_TextEncoding) 64)) }, |
514 | { "mskanji", RTL_TEXTENCODING_MS_932(((rtl_TextEncoding) 60)) }, |
515 | { "gb2312", RTL_TEXTENCODING_GB_2312(((rtl_TextEncoding) 65)) }, |
516 | { "cngb", RTL_TEXTENCODING_GB_2312(((rtl_TextEncoding) 65)) }, |
517 | { "big5", RTL_TEXTENCODING_BIG5(((rtl_TextEncoding) 68)) }, |
518 | { "cnbig5", RTL_TEXTENCODING_BIG5(((rtl_TextEncoding) 68)) }, |
519 | { "cngb12345", RTL_TEXTENCODING_GBT_12345(((rtl_TextEncoding) 66)) }, |
520 | { "euckr", RTL_TEXTENCODING_EUC_KR(((rtl_TextEncoding) 79)) }, |
521 | { "koi8r", RTL_TEXTENCODING_KOI8_R(((rtl_TextEncoding) 74)) }, |
522 | { "windows1252", RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)) }, |
523 | { "windows1250", RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)) }, |
524 | { "windows1251", RTL_TEXTENCODING_MS_1251(((rtl_TextEncoding) 34)) }, |
525 | { "windows1253", RTL_TEXTENCODING_MS_1253(((rtl_TextEncoding) 35)) }, |
526 | { "windows1254", RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)) }, |
527 | { "windows1255", RTL_TEXTENCODING_MS_1255(((rtl_TextEncoding) 37)) }, |
528 | { "windows1256", RTL_TEXTENCODING_MS_1256(((rtl_TextEncoding) 38)) }, |
529 | { "windows1257", RTL_TEXTENCODING_MS_1257(((rtl_TextEncoding) 39)) }, |
530 | { "windows1258", RTL_TEXTENCODING_MS_1258(((rtl_TextEncoding) 40)) }, |
531 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
532 | }; |
533 | |
534 | |
535 | |
536 | |
537 | |
538 | static ImplStrCharsetDef const aMimeCharsetTab[] = |
539 | { |
540 | { "unicode11utf7", RTL_TEXTENCODING_UTF7(((rtl_TextEncoding) 75)) }, |
541 | { "caunicode11utf7", RTL_TEXTENCODING_UTF7(((rtl_TextEncoding) 75)) }, |
542 | { "iso88591windows30", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
543 | { "iso88591win", RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)) }, |
544 | { "iso88592win", RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)) }, |
545 | { "iso88599win", RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)) }, |
546 | { "iso885915", RTL_TEXTENCODING_ISO_8859_15(((rtl_TextEncoding) 22)) }, |
547 | { "iso885914", RTL_TEXTENCODING_ISO_8859_14(((rtl_TextEncoding) 21)) }, |
548 | { "iso885913", RTL_TEXTENCODING_ISO_8859_13(((rtl_TextEncoding) 78)) }, |
549 | { "iso885911", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
550 | |
551 | |
552 | { "iso885910", RTL_TEXTENCODING_ISO_8859_10(((rtl_TextEncoding) 77)) }, |
553 | { "iso88591", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
554 | { "iso88592", RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)) }, |
555 | { "iso88593", RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)) }, |
556 | { "iso88594", RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)) }, |
557 | { "iso88595", RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)) }, |
558 | { "iso88596", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
559 | { "iso88597", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
560 | { "iso88598", RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)) }, |
561 | { "iso88599", RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)) }, |
562 | { "isoir100", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
563 | { "latin1", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
564 | { "l1", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
565 | { "cp819", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
566 | { "ibm819", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
567 | { "csisolatin1", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
568 | { "isoir101", RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)) }, |
569 | { "latin2", RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)) }, |
570 | { "l2", RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)) }, |
571 | { "csisolatin2", RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)) }, |
572 | { "isoir109", RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)) }, |
573 | { "latin3", RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)) }, |
574 | { "l3", RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)) }, |
575 | { "csisolatin3", RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)) }, |
576 | { "isoir110", RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)) }, |
577 | { "latin4", RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)) }, |
578 | { "l4", RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)) }, |
579 | { "csisolatin4", RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)) }, |
580 | { "isoir144", RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)) }, |
581 | { "cyrillicasian", RTL_TEXTENCODING_PT154(((rtl_TextEncoding) 93)) }, |
582 | { "cyrillic", RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)) }, |
583 | { "csisolatincyrillic", RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)) }, |
584 | { "isoir127", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
585 | { "arabic", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
586 | { "csisolatinarabic", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
587 | { "ecma114", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
588 | { "asmo708", RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)) }, |
589 | { "isoir126", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
590 | { "greek", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
591 | { "csisolatingreek", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
592 | { "elot928", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
593 | { "ecma118", RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)) }, |
594 | { "isoir138", RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)) }, |
595 | { "hebrew", RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)) }, |
596 | { "csisolatinhebrew", RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)) }, |
597 | { "isoir148", RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)) }, |
598 | { "latin5", RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)) }, |
599 | { "l5", RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)) }, |
600 | { "csisolatin5", RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)) }, |
601 | { "cswindows30latin1", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
602 | { "cswindows30latin1", RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)) }, |
603 | { "cswindows31latin1", RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)) }, |
604 | { "cswindows31latin2", RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)) }, |
605 | { "cswindows31latin5", RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)) }, |
606 | { "iso10646us", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
607 | { "iso646irv", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
608 | { "cskoi8r", RTL_TEXTENCODING_KOI8_R(((rtl_TextEncoding) 74)) }, |
609 | { "ibm437", RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)) }, |
610 | { "cp437", RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)) }, |
611 | { "437", RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)) }, |
612 | { "cspc8codepage437", RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)) }, |
613 | { "ansix34", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
614 | { "ibm367", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
615 | { "cp367", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
616 | { "csascii", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
617 | { "ibm775", RTL_TEXTENCODING_IBM_775(((rtl_TextEncoding) 24)) }, |
618 | { "cp775", RTL_TEXTENCODING_IBM_775(((rtl_TextEncoding) 24)) }, |
619 | { "cspc775baltic", RTL_TEXTENCODING_IBM_775(((rtl_TextEncoding) 24)) }, |
620 | { "ibm850", RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)) }, |
621 | { "cp850", RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)) }, |
622 | { "850", RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)) }, |
623 | { "cspc850multilingual", RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)) }, |
624 | |
625 | |
626 | |
627 | |
628 | { "ibm852", RTL_TEXTENCODING_IBM_852(((rtl_TextEncoding) 25)) }, |
629 | { "cp852", RTL_TEXTENCODING_IBM_852(((rtl_TextEncoding) 25)) }, |
630 | { "852", RTL_TEXTENCODING_IBM_852(((rtl_TextEncoding) 25)) }, |
631 | { "cspcp852", RTL_TEXTENCODING_IBM_852(((rtl_TextEncoding) 25)) }, |
632 | { "ibm855", RTL_TEXTENCODING_IBM_855(((rtl_TextEncoding) 26)) }, |
633 | { "cp855", RTL_TEXTENCODING_IBM_855(((rtl_TextEncoding) 26)) }, |
634 | { "855", RTL_TEXTENCODING_IBM_855(((rtl_TextEncoding) 26)) }, |
635 | { "csibm855", RTL_TEXTENCODING_IBM_855(((rtl_TextEncoding) 26)) }, |
636 | { "ibm857", RTL_TEXTENCODING_IBM_857(((rtl_TextEncoding) 27)) }, |
637 | { "cp857", RTL_TEXTENCODING_IBM_857(((rtl_TextEncoding) 27)) }, |
638 | { "857", RTL_TEXTENCODING_IBM_857(((rtl_TextEncoding) 27)) }, |
639 | { "csibm857", RTL_TEXTENCODING_IBM_857(((rtl_TextEncoding) 27)) }, |
640 | { "ibm860", RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)) }, |
641 | { "cp860", RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)) }, |
642 | { "860", RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)) }, |
643 | { "csibm860", RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)) }, |
644 | { "ibm861", RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)) }, |
645 | { "cp861", RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)) }, |
646 | { "861", RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)) }, |
647 | { "csis", RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)) }, |
648 | { "csibm861", RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)) }, |
649 | { "ibm862", RTL_TEXTENCODING_IBM_862(((rtl_TextEncoding) 28)) }, |
650 | { "cp862", RTL_TEXTENCODING_IBM_862(((rtl_TextEncoding) 28)) }, |
651 | { "862", RTL_TEXTENCODING_IBM_862(((rtl_TextEncoding) 28)) }, |
652 | { "cspc862latinhebrew", RTL_TEXTENCODING_IBM_862(((rtl_TextEncoding) 28)) }, |
653 | { "ibm863", RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)) }, |
654 | { "cp863", RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)) }, |
655 | { "863", RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)) }, |
656 | { "csibm863", RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)) }, |
657 | { "ibm864", RTL_TEXTENCODING_IBM_864(((rtl_TextEncoding) 29)) }, |
658 | { "cp864", RTL_TEXTENCODING_IBM_864(((rtl_TextEncoding) 29)) }, |
659 | { "864", RTL_TEXTENCODING_IBM_864(((rtl_TextEncoding) 29)) }, |
660 | { "csibm864", RTL_TEXTENCODING_IBM_864(((rtl_TextEncoding) 29)) }, |
661 | { "ibm865", RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)) }, |
662 | { "cp865", RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)) }, |
663 | { "865", RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)) }, |
664 | { "csibm865", RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)) }, |
665 | { "ibm866", RTL_TEXTENCODING_IBM_866(((rtl_TextEncoding) 30)) }, |
666 | { "cp866", RTL_TEXTENCODING_IBM_866(((rtl_TextEncoding) 30)) }, |
667 | { "866", RTL_TEXTENCODING_IBM_866(((rtl_TextEncoding) 30)) }, |
668 | { "csibm866", RTL_TEXTENCODING_IBM_866(((rtl_TextEncoding) 30)) }, |
669 | |
670 | |
671 | |
672 | |
673 | { "ibm869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
674 | { "cp869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
675 | { "869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
676 | { "cpgr", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
677 | { "csibm869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
678 | { "ibm869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
679 | { "cp869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
680 | { "869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
681 | { "cpgr", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
682 | { "csibm869", RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)) }, |
683 | { "mac", RTL_TEXTENCODING_APPLE_ROMAN(((rtl_TextEncoding) 2)) }, |
684 | { "csmacintosh", RTL_TEXTENCODING_APPLE_ROMAN(((rtl_TextEncoding) 2)) }, |
685 | { "shiftjis", RTL_TEXTENCODING_SHIFT_JIS(((rtl_TextEncoding) 64)) }, |
686 | { "mskanji", RTL_TEXTENCODING_MS_932(((rtl_TextEncoding) 60)) }, |
687 | { "csshiftjis", RTL_TEXTENCODING_SHIFT_JIS(((rtl_TextEncoding) 64)) }, |
688 | { "jisx0208", RTL_TEXTENCODING_JIS_X_0208(((rtl_TextEncoding) 82)) }, |
689 | { "jisc62261983", RTL_TEXTENCODING_JIS_X_0208(((rtl_TextEncoding) 82)) }, |
690 | { "csiso87jisx0208", RTL_TEXTENCODING_JIS_X_0208(((rtl_TextEncoding) 82)) }, |
691 | { "isoir86", RTL_TEXTENCODING_JIS_X_0208(((rtl_TextEncoding) 82)) }, |
692 | { "x0208", RTL_TEXTENCODING_JIS_X_0208(((rtl_TextEncoding) 82)) }, |
693 | { "jisx0201", RTL_TEXTENCODING_JIS_X_0201(((rtl_TextEncoding) 81)) }, |
694 | { "cshalfwidthkatakana", RTL_TEXTENCODING_JIS_X_0201(((rtl_TextEncoding) 81)) }, |
695 | { "x0201", RTL_TEXTENCODING_JIS_X_0201(((rtl_TextEncoding) 81)) }, |
696 | { "jisx0212", RTL_TEXTENCODING_JIS_X_0212(((rtl_TextEncoding) 83)) }, |
697 | { "csiso159jisx0212", RTL_TEXTENCODING_JIS_X_0212(((rtl_TextEncoding) 83)) }, |
698 | { "isoir159", RTL_TEXTENCODING_JIS_X_0208(((rtl_TextEncoding) 82)) }, |
699 | { "x0212", RTL_TEXTENCODING_JIS_X_0212(((rtl_TextEncoding) 83)) }, |
700 | { "isoir6", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
701 | { "xsjis", RTL_TEXTENCODING_SHIFT_JIS(((rtl_TextEncoding) 64)) }, |
702 | { "sjis", RTL_TEXTENCODING_SHIFT_JIS(((rtl_TextEncoding) 64)) }, |
703 | { "ascii", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
704 | { "us", RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) }, |
705 | { "gb180302000", RTL_TEXTENCODING_GB_18030(((rtl_TextEncoding) 85)) }, |
706 | |
707 | |
708 | |
709 | |
710 | { "gb18030", RTL_TEXTENCODING_GB_18030(((rtl_TextEncoding) 85)) }, |
711 | { "big5hkscs", RTL_TEXTENCODING_BIG5_HKSCS(((rtl_TextEncoding) 86)) }, |
712 | { "tis620", RTL_TEXTENCODING_TIS_620(((rtl_TextEncoding) 87)) }, |
713 | { "gbk", RTL_TEXTENCODING_GBK(((rtl_TextEncoding) 67)) }, |
714 | { "cp936", RTL_TEXTENCODING_GBK(((rtl_TextEncoding) 67)) }, |
715 | { "ms936", RTL_TEXTENCODING_GBK(((rtl_TextEncoding) 67)) }, |
716 | { "windows936", RTL_TEXTENCODING_GBK(((rtl_TextEncoding) 67)) }, |
717 | { "cp874", RTL_TEXTENCODING_MS_874(((rtl_TextEncoding) 32)) }, |
718 | |
719 | |
720 | { "ms874", RTL_TEXTENCODING_MS_874(((rtl_TextEncoding) 32)) }, |
721 | |
722 | |
723 | { "windows874", RTL_TEXTENCODING_MS_874(((rtl_TextEncoding) 32)) }, |
724 | |
725 | |
726 | { "koi8u", RTL_TEXTENCODING_KOI8_U(((rtl_TextEncoding) 88)) }, |
727 | { "cpis", RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)) }, |
728 | { "ksc56011987", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
729 | { "isoir149", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
730 | { "ksc56011989", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
731 | { "ksc5601", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
732 | { "korean", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
733 | { "csksc56011987", RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)) }, |
734 | |
735 | |
736 | |
737 | { "latin9", RTL_TEXTENCODING_ISO_8859_15(((rtl_TextEncoding) 22)) }, |
738 | { "adobestandardencoding", RTL_TEXTENCODING_ADOBE_STANDARD(((rtl_TextEncoding) 91)) }, |
739 | { "csadobestandardencoding", RTL_TEXTENCODING_ADOBE_STANDARD(((rtl_TextEncoding) 91)) }, |
740 | { "adobesymbolencoding", RTL_TEXTENCODING_ADOBE_SYMBOL(((rtl_TextEncoding) 92)) }, |
741 | { "cshppsmath", RTL_TEXTENCODING_ADOBE_SYMBOL(((rtl_TextEncoding) 92)) }, |
742 | { "ptcp154", RTL_TEXTENCODING_PT154(((rtl_TextEncoding) 93)) }, |
743 | { "csptcp154", RTL_TEXTENCODING_PT154(((rtl_TextEncoding) 93)) }, |
744 | { "pt154", RTL_TEXTENCODING_PT154(((rtl_TextEncoding) 93)) }, |
745 | { "cp154", RTL_TEXTENCODING_PT154(((rtl_TextEncoding) 93)) }, |
746 | { "xisciide", RTL_TEXTENCODING_ISCII_DEVANAGARI(((rtl_TextEncoding) 89)) }, |
747 | |
748 | |
749 | { NULL__null, RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) } |
750 | }; |
751 | |
752 | rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)); |
753 | char* pBuf; |
754 | const ImplStrCharsetDef* pData = aVIPMimeCharsetTab; |
755 | sal_uInt32 nBufLen = strlen( pMimeCharset )+1; |
756 | |
757 | |
758 | pBuf = new char[nBufLen]; |
759 | Impl_toAsciiLowerAndRemoveNonAlphanumeric( pMimeCharset, pBuf ); |
760 | |
761 | |
762 | while ( pData->mpCharsetStr ) |
763 | { |
764 | if ( strcmp( pBuf, pData->mpCharsetStr ) == 0 ) |
765 | { |
766 | eEncoding = pData->meTextEncoding; |
767 | break; |
768 | } |
769 | |
770 | pData++; |
771 | } |
772 | |
773 | |
774 | if ( eEncoding == RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)) ) |
775 | { |
776 | pData = aMimeCharsetTab; |
777 | while ( pData->mpCharsetStr ) |
778 | { |
779 | if ( Impl_matchString( pBuf, pData->mpCharsetStr ) ) |
780 | { |
781 | eEncoding = pData->meTextEncoding; |
782 | break; |
783 | } |
784 | |
785 | pData++; |
786 | } |
787 | } |
788 | |
789 | delete[] pBuf; |
790 | |
791 | return eEncoding; |
792 | } |
793 | |
794 | |
795 | |
796 | sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) |
797 | { |
798 | const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding ); |
799 | if ( pData ) |
800 | return pData->mnBestWindowsCharset; |
801 | else |
802 | return 1; |
803 | } |
804 | |
805 | |
806 | |
807 | const char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) |
808 | { |
809 | const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding ); |
810 | if ( pData ) |
811 | return (char const *) pData->mpBestUnixCharset; |
812 | else if( eTextEncoding == RTL_TEXTENCODING_UNICODE(((rtl_TextEncoding) 0xFFFF)) ) |
813 | return (char const *) "iso10646-1"; |
814 | else |
815 | return 0; |
816 | } |
817 | |
818 | |
819 | |
820 | char const * SAL_CALL rtl_getMimeCharsetFromTextEncoding(rtl_TextEncoding |
821 | nEncoding) |
822 | { |
823 | ImplTextEncodingData const * p = Impl_getTextEncodingData(nEncoding); |
824 | return p && (p->mnInfoFlags & RTL_TEXTENCODING_INFO_MIME((sal_uInt32)0x00000080)) != 0 ? |
825 | p->mpBestMimeCharset : NULL__null; |
826 | } |
827 | |
828 | const char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) |
829 | { |
830 | const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding ); |
831 | if ( pData ) |
832 | return (char const *) pData->mpBestMimeCharset; |
833 | else |
834 | return 0; |
835 | } |
836 | |
837 | |
838 | |
839 | |
840 | |
841 | |
842 | rtl_TextEncoding SAL_CALL |
843 | rtl_getTextEncodingFromWindowsCodePage(sal_uInt32 nCodePage) |
844 | { |
845 | switch (nCodePage) |
846 | { |
847 | case 437: return RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)); |
848 | case 708: return RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)); |
849 | case 737: return RTL_TEXTENCODING_IBM_737(((rtl_TextEncoding) 23)); |
850 | case 775: return RTL_TEXTENCODING_IBM_775(((rtl_TextEncoding) 24)); |
851 | case 850: return RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)); |
852 | case 852: return RTL_TEXTENCODING_IBM_852(((rtl_TextEncoding) 25)); |
853 | case 855: return RTL_TEXTENCODING_IBM_855(((rtl_TextEncoding) 26)); |
854 | case 857: return RTL_TEXTENCODING_IBM_857(((rtl_TextEncoding) 27)); |
855 | case 860: return RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)); |
856 | case 861: return RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)); |
857 | case 862: return RTL_TEXTENCODING_IBM_862(((rtl_TextEncoding) 28)); |
858 | case 863: return RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)); |
859 | case 864: return RTL_TEXTENCODING_IBM_864(((rtl_TextEncoding) 29)); |
860 | case 865: return RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)); |
861 | case 866: return RTL_TEXTENCODING_IBM_866(((rtl_TextEncoding) 30)); |
862 | case 869: return RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)); |
863 | case 874: return RTL_TEXTENCODING_MS_874(((rtl_TextEncoding) 32)); |
864 | case 932: return RTL_TEXTENCODING_MS_932(((rtl_TextEncoding) 60)); |
865 | case 936: return RTL_TEXTENCODING_MS_936(((rtl_TextEncoding) 61)); |
866 | case 949: return RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)); |
867 | case 950: return RTL_TEXTENCODING_MS_950(((rtl_TextEncoding) 63)); |
868 | case 1250: return RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)); |
869 | case 1251: return RTL_TEXTENCODING_MS_1251(((rtl_TextEncoding) 34)); |
870 | case 1252: return RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)); |
871 | case 1253: return RTL_TEXTENCODING_MS_1253(((rtl_TextEncoding) 35)); |
872 | case 1254: return RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)); |
873 | case 1255: return RTL_TEXTENCODING_MS_1255(((rtl_TextEncoding) 37)); |
874 | case 1256: return RTL_TEXTENCODING_MS_1256(((rtl_TextEncoding) 38)); |
875 | case 1257: return RTL_TEXTENCODING_MS_1257(((rtl_TextEncoding) 39)); |
876 | case 1258: return RTL_TEXTENCODING_MS_1258(((rtl_TextEncoding) 40)); |
877 | case 1361: return RTL_TEXTENCODING_MS_1361(((rtl_TextEncoding) 84)); |
878 | case 10000: return RTL_TEXTENCODING_APPLE_ROMAN(((rtl_TextEncoding) 2)); |
879 | case 10001: return RTL_TEXTENCODING_APPLE_JAPANESE(((rtl_TextEncoding) 58)); |
880 | case 10002: return RTL_TEXTENCODING_APPLE_CHINTRAD(((rtl_TextEncoding) 57)); |
881 | case 10003: return RTL_TEXTENCODING_APPLE_KOREAN(((rtl_TextEncoding) 59)); |
882 | case 10004: return RTL_TEXTENCODING_APPLE_ARABIC(((rtl_TextEncoding) 41)); |
883 | case 10005: return RTL_TEXTENCODING_APPLE_HEBREW(((rtl_TextEncoding) 50)); |
884 | case 10006: return RTL_TEXTENCODING_APPLE_GREEK(((rtl_TextEncoding) 47)); |
885 | case 10007: return RTL_TEXTENCODING_APPLE_CYRILLIC(((rtl_TextEncoding) 44)); |
886 | case 10008: return RTL_TEXTENCODING_APPLE_CHINSIMP(((rtl_TextEncoding) 56)); |
887 | case 10010: return RTL_TEXTENCODING_APPLE_ROMANIAN(((rtl_TextEncoding) 52)); |
888 | case 10017: return RTL_TEXTENCODING_APPLE_UKRAINIAN(((rtl_TextEncoding) 55)); |
889 | case 10029: return RTL_TEXTENCODING_APPLE_CENTEURO(((rtl_TextEncoding) 42)); |
890 | case 10079: return RTL_TEXTENCODING_APPLE_ICELAND(((rtl_TextEncoding) 51)); |
891 | case 10081: return RTL_TEXTENCODING_APPLE_TURKISH(((rtl_TextEncoding) 54)); |
892 | case 10082: return RTL_TEXTENCODING_APPLE_CROATIAN(((rtl_TextEncoding) 43)); |
893 | case 20127: return RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)); |
894 | case 20866: return RTL_TEXTENCODING_KOI8_R(((rtl_TextEncoding) 74)); |
895 | case 21866: return RTL_TEXTENCODING_KOI8_U(((rtl_TextEncoding) 88)); |
896 | case 28591: return RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)); |
897 | case 28592: return RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)); |
898 | case 28593: return RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)); |
899 | case 28594: return RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)); |
900 | case 28595: return RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)); |
901 | case 28596: return RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)); |
902 | case 28597: return RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)); |
903 | case 28598: return RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)); |
904 | case 28599: return RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)); |
905 | case 28605: return RTL_TEXTENCODING_ISO_8859_15(((rtl_TextEncoding) 22)); |
906 | case 50220: return RTL_TEXTENCODING_ISO_2022_JP(((rtl_TextEncoding) 72)); |
907 | case 50225: return RTL_TEXTENCODING_ISO_2022_KR(((rtl_TextEncoding) 80)); |
908 | case 51932: return RTL_TEXTENCODING_EUC_JP(((rtl_TextEncoding) 69)); |
909 | case 51936: return RTL_TEXTENCODING_EUC_CN(((rtl_TextEncoding) 70)); |
910 | case 51949: return RTL_TEXTENCODING_EUC_KR(((rtl_TextEncoding) 79)); |
911 | case 57002: return RTL_TEXTENCODING_ISCII_DEVANAGARI(((rtl_TextEncoding) 89)); |
912 | case 65000: return RTL_TEXTENCODING_UTF7(((rtl_TextEncoding) 75)); |
913 | case 65001: return RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)); |
914 | default: return RTL_TEXTENCODING_DONTKNOW(((rtl_TextEncoding) 0)); |
915 | } |
916 | } |
917 | |
918 | sal_uInt32 SAL_CALL |
919 | rtl_getWindowsCodePageFromTextEncoding(rtl_TextEncoding nEncoding) |
920 | { |
921 | switch (nEncoding) |
922 | { |
923 | case RTL_TEXTENCODING_IBM_437(((rtl_TextEncoding) 3)): return 437; |
924 | |
925 | case RTL_TEXTENCODING_IBM_737(((rtl_TextEncoding) 23)): return 737; |
926 | case RTL_TEXTENCODING_IBM_775(((rtl_TextEncoding) 24)): return 775; |
927 | case RTL_TEXTENCODING_IBM_850(((rtl_TextEncoding) 4)): return 850; |
928 | case RTL_TEXTENCODING_IBM_852(((rtl_TextEncoding) 25)): return 852; |
929 | case RTL_TEXTENCODING_IBM_855(((rtl_TextEncoding) 26)): return 855; |
930 | case RTL_TEXTENCODING_IBM_857(((rtl_TextEncoding) 27)): return 857; |
931 | case RTL_TEXTENCODING_IBM_860(((rtl_TextEncoding) 5)): return 860; |
932 | case RTL_TEXTENCODING_IBM_861(((rtl_TextEncoding) 6)): return 861; |
933 | case RTL_TEXTENCODING_IBM_862(((rtl_TextEncoding) 28)): return 862; |
934 | case RTL_TEXTENCODING_IBM_863(((rtl_TextEncoding) 7)): return 863; |
935 | case RTL_TEXTENCODING_IBM_864(((rtl_TextEncoding) 29)): return 864; |
936 | case RTL_TEXTENCODING_IBM_865(((rtl_TextEncoding) 8)): return 865; |
937 | case RTL_TEXTENCODING_IBM_866(((rtl_TextEncoding) 30)): return 866; |
938 | case RTL_TEXTENCODING_IBM_869(((rtl_TextEncoding) 31)): return 869; |
939 | case RTL_TEXTENCODING_MS_874(((rtl_TextEncoding) 32)): return 874; |
940 | case RTL_TEXTENCODING_MS_932(((rtl_TextEncoding) 60)): return 932; |
941 | case RTL_TEXTENCODING_MS_936(((rtl_TextEncoding) 61)): return 936; |
942 | case RTL_TEXTENCODING_MS_949(((rtl_TextEncoding) 62)): return 949; |
943 | case RTL_TEXTENCODING_MS_950(((rtl_TextEncoding) 63)): return 950; |
944 | case RTL_TEXTENCODING_MS_1250(((rtl_TextEncoding) 33)): return 1250; |
945 | case RTL_TEXTENCODING_MS_1251(((rtl_TextEncoding) 34)): return 1251; |
946 | case RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)): return 1252; |
947 | case RTL_TEXTENCODING_MS_1253(((rtl_TextEncoding) 35)): return 1253; |
948 | case RTL_TEXTENCODING_MS_1254(((rtl_TextEncoding) 36)): return 1254; |
949 | case RTL_TEXTENCODING_MS_1255(((rtl_TextEncoding) 37)): return 1255; |
950 | case RTL_TEXTENCODING_MS_1256(((rtl_TextEncoding) 38)): return 1256; |
951 | case RTL_TEXTENCODING_MS_1257(((rtl_TextEncoding) 39)): return 1257; |
952 | case RTL_TEXTENCODING_MS_1258(((rtl_TextEncoding) 40)): return 1258; |
953 | case RTL_TEXTENCODING_MS_1361(((rtl_TextEncoding) 84)): return 1361; |
954 | case RTL_TEXTENCODING_APPLE_ROMAN(((rtl_TextEncoding) 2)): return 10000; |
955 | case RTL_TEXTENCODING_APPLE_JAPANESE(((rtl_TextEncoding) 58)): return 10001; |
956 | case RTL_TEXTENCODING_APPLE_CHINTRAD(((rtl_TextEncoding) 57)): return 10002; |
957 | case RTL_TEXTENCODING_APPLE_KOREAN(((rtl_TextEncoding) 59)): return 10003; |
958 | case RTL_TEXTENCODING_APPLE_ARABIC(((rtl_TextEncoding) 41)): return 10004; |
959 | case RTL_TEXTENCODING_APPLE_HEBREW(((rtl_TextEncoding) 50)): return 10005; |
960 | case RTL_TEXTENCODING_APPLE_GREEK(((rtl_TextEncoding) 47)): return 10006; |
961 | case RTL_TEXTENCODING_APPLE_CYRILLIC(((rtl_TextEncoding) 44)): return 10007; |
962 | case RTL_TEXTENCODING_APPLE_CHINSIMP(((rtl_TextEncoding) 56)): return 10008; |
963 | case RTL_TEXTENCODING_APPLE_ROMANIAN(((rtl_TextEncoding) 52)): return 10010; |
964 | case RTL_TEXTENCODING_APPLE_UKRAINIAN(((rtl_TextEncoding) 55)): return 10017; |
965 | case RTL_TEXTENCODING_APPLE_CENTEURO(((rtl_TextEncoding) 42)): return 10029; |
966 | case RTL_TEXTENCODING_APPLE_ICELAND(((rtl_TextEncoding) 51)): return 10079; |
967 | case RTL_TEXTENCODING_APPLE_TURKISH(((rtl_TextEncoding) 54)): return 10081; |
968 | case RTL_TEXTENCODING_APPLE_CROATIAN(((rtl_TextEncoding) 43)): return 10082; |
969 | case RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)): return 20127; |
970 | case RTL_TEXTENCODING_KOI8_R(((rtl_TextEncoding) 74)): return 20866; |
971 | case RTL_TEXTENCODING_KOI8_U(((rtl_TextEncoding) 88)): return 21866; |
972 | case RTL_TEXTENCODING_ISO_8859_1(((rtl_TextEncoding) 12)): return 28591; |
973 | case RTL_TEXTENCODING_ISO_8859_2(((rtl_TextEncoding) 13)): return 28592; |
974 | case RTL_TEXTENCODING_ISO_8859_3(((rtl_TextEncoding) 14)): return 28593; |
975 | case RTL_TEXTENCODING_ISO_8859_4(((rtl_TextEncoding) 15)): return 28594; |
976 | case RTL_TEXTENCODING_ISO_8859_5(((rtl_TextEncoding) 16)): return 28595; |
977 | case RTL_TEXTENCODING_ISO_8859_6(((rtl_TextEncoding) 17)): return 28596; |
978 | case RTL_TEXTENCODING_ISO_8859_7(((rtl_TextEncoding) 18)): return 28597; |
979 | case RTL_TEXTENCODING_ISO_8859_8(((rtl_TextEncoding) 19)): return 28598; |
980 | case RTL_TEXTENCODING_ISO_8859_9(((rtl_TextEncoding) 20)): return 28599; |
981 | case RTL_TEXTENCODING_ISO_8859_15(((rtl_TextEncoding) 22)): return 28605; |
982 | case RTL_TEXTENCODING_ISO_2022_JP(((rtl_TextEncoding) 72)): return 50220; |
983 | case RTL_TEXTENCODING_ISO_2022_KR(((rtl_TextEncoding) 80)): return 50225; |
984 | case RTL_TEXTENCODING_EUC_JP(((rtl_TextEncoding) 69)): return 51932; |
985 | case RTL_TEXTENCODING_EUC_CN(((rtl_TextEncoding) 70)): return 51936; |
986 | case RTL_TEXTENCODING_EUC_KR(((rtl_TextEncoding) 79)): return 51949; |
987 | case RTL_TEXTENCODING_ISCII_DEVANAGARI(((rtl_TextEncoding) 89)): return 57002; |
988 | case RTL_TEXTENCODING_UTF7(((rtl_TextEncoding) 75)): return 65000; |
989 | case RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)): return 65001; |
990 | default: return 0; |
991 | } |
992 | } |
993 | |
994 | |