xref: /aoo42x/main/sal/textenc/tencinfo.c (revision 647f063d)
1*647f063dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*647f063dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*647f063dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*647f063dSAndrew Rist  * distributed with this work for additional information
6*647f063dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*647f063dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*647f063dSAndrew Rist  * "License"); you may not use this file except in compliance
9*647f063dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*647f063dSAndrew Rist  *
11*647f063dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*647f063dSAndrew Rist  *
13*647f063dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*647f063dSAndrew Rist  * software distributed under the License is distributed on an
15*647f063dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*647f063dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*647f063dSAndrew Rist  * specific language governing permissions and limitations
18*647f063dSAndrew Rist  * under the License.
19*647f063dSAndrew Rist  *
20*647f063dSAndrew Rist  *************************************************************/
21*647f063dSAndrew Rist 
22*647f063dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "rtl/tencinfo.h"
25cdf0e10cSrcweir #include "gettextencodingdata.h"
26cdf0e10cSrcweir #include "tenchelp.h"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _RTL_ALLOC_H
29cdf0e10cSrcweir #include "rtl/alloc.h"
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #ifndef INCLUDED_STDDEF_H
33cdf0e10cSrcweir #include <stddef.h>
34cdf0e10cSrcweir #define INCLUDED_STDDEF_H
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef INCLUDED_STRING_H
37cdf0e10cSrcweir #include <string.h>
38cdf0e10cSrcweir #define INCLUDED_STRING_H
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir 
41cdf0e10cSrcweir sal_Bool SAL_CALL rtl_isOctetTextEncoding(rtl_TextEncoding nEncoding)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     return (sal_Bool)
44cdf0e10cSrcweir         (nEncoding > RTL_TEXTENCODING_DONTKNOW
45cdf0e10cSrcweir          && (nEncoding <= RTL_TEXTENCODING_ADOBE_DINGBATS)
46cdf0e10cSrcweir              /* always update this! */
47cdf0e10cSrcweir          && nEncoding != 9); /* RTL_TEXTENCODING_SYSTEM */
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir /* ======================================================================= */
51cdf0e10cSrcweir 
52cdf0e10cSrcweir static void Impl_toAsciiLower( const sal_Char* pName, sal_Char* pBuf )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir     while ( *pName )
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir         /* A-Z */
57cdf0e10cSrcweir         if ( (*pName >= 0x41) && (*pName <= 0x5A) )
58cdf0e10cSrcweir             *pBuf = (*pName)+0x20;  /* toAsciiLower */
59cdf0e10cSrcweir         else
60cdf0e10cSrcweir             *pBuf = *pName;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         pBuf++;
63cdf0e10cSrcweir         pName++;
64cdf0e10cSrcweir     }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     *pBuf = '\0';
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir /* ----------------------------------------------------------------------- */
70cdf0e10cSrcweir 
71cdf0e10cSrcweir static void Impl_toAsciiLowerAndRemoveNonAlphanumeric( const sal_Char* pName, sal_Char* pBuf )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     while ( *pName )
74cdf0e10cSrcweir     {
75cdf0e10cSrcweir         /* A-Z */
76cdf0e10cSrcweir         if ( (*pName >= 0x41) && (*pName <= 0x5A) )
77cdf0e10cSrcweir         {
78cdf0e10cSrcweir             *pBuf = (*pName)+0x20;  /* toAsciiLower */
79cdf0e10cSrcweir             pBuf++;
80cdf0e10cSrcweir         }
81cdf0e10cSrcweir         /* a-z, 0-9 */
82cdf0e10cSrcweir         else if ( ((*pName >= 0x61) && (*pName <= 0x7A)) ||
83cdf0e10cSrcweir                   ((*pName >= 0x30) && (*pName <= 0x39)) )
84cdf0e10cSrcweir         {
85cdf0e10cSrcweir             *pBuf = *pName;
86cdf0e10cSrcweir             pBuf++;
87cdf0e10cSrcweir         }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         pName++;
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     *pBuf = '\0';
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /* ----------------------------------------------------------------------- */
96cdf0e10cSrcweir 
97cdf0e10cSrcweir /* pMatchStr must match with all characters in pCompStr */
98cdf0e10cSrcweir static sal_Bool Impl_matchString( const sal_Char* pCompStr, const sal_Char* pMatchStr )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir     /* We test only for end in MatchStr, because the last 0 character from */
101cdf0e10cSrcweir     /* pCompStr is unequal a character in MatchStr, so the loop terminates */
102cdf0e10cSrcweir     while ( *pMatchStr )
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         if ( *pCompStr != *pMatchStr )
105cdf0e10cSrcweir             return sal_False;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         pCompStr++;
108cdf0e10cSrcweir         pMatchStr++;
109cdf0e10cSrcweir     }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     return sal_True;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir /* ======================================================================= */
115cdf0e10cSrcweir 
116cdf0e10cSrcweir typedef struct
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     const sal_Char*             mpCharsetStr;
119cdf0e10cSrcweir     rtl_TextEncoding            meTextEncoding;
120cdf0e10cSrcweir } ImplStrCharsetDef;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir typedef struct
123cdf0e10cSrcweir {
124cdf0e10cSrcweir     const sal_Char*             mpCharsetStr;
125cdf0e10cSrcweir     const ImplStrCharsetDef*    mpSecondPartTab;
126cdf0e10cSrcweir } ImplStrFirstPartCharsetDef;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir /* ======================================================================= */
129cdf0e10cSrcweir 
130cdf0e10cSrcweir sal_Bool SAL_CALL rtl_getTextEncodingInfo( rtl_TextEncoding eTextEncoding, rtl_TextEncodingInfo* pEncInfo )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     const ImplTextEncodingData* pData;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     pData = Impl_getTextEncodingData( eTextEncoding );
135cdf0e10cSrcweir     if ( !pData )
136cdf0e10cSrcweir     {
137cdf0e10cSrcweir         /* HACK: For not implemented encoding, because not all
138cdf0e10cSrcweir            calls handle the errors */
139cdf0e10cSrcweir         if ( pEncInfo->StructSize < 5 )
140cdf0e10cSrcweir             return sal_False;
141cdf0e10cSrcweir         pEncInfo->MinimumCharSize = 1;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir         if ( pEncInfo->StructSize < 6 )
144cdf0e10cSrcweir             return sal_True;
145cdf0e10cSrcweir         pEncInfo->MaximumCharSize = 1;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         if ( pEncInfo->StructSize < 7 )
148cdf0e10cSrcweir             return sal_True;
149cdf0e10cSrcweir         pEncInfo->AverageCharSize = 1;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         if ( pEncInfo->StructSize < 12 )
152cdf0e10cSrcweir             return sal_True;
153cdf0e10cSrcweir         pEncInfo->Flags = 0;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir         return sal_False;
156cdf0e10cSrcweir     }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     if ( pEncInfo->StructSize < 5 )
159cdf0e10cSrcweir         return sal_False;
160cdf0e10cSrcweir     pEncInfo->MinimumCharSize = pData->mnMinCharSize;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     if ( pEncInfo->StructSize < 6 )
163cdf0e10cSrcweir         return sal_True;
164cdf0e10cSrcweir     pEncInfo->MaximumCharSize = pData->mnMaxCharSize;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     if ( pEncInfo->StructSize < 7 )
167cdf0e10cSrcweir         return sal_True;
168cdf0e10cSrcweir     pEncInfo->AverageCharSize = pData->mnAveCharSize;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     if ( pEncInfo->StructSize < 12 )
171cdf0e10cSrcweir         return sal_True;
172cdf0e10cSrcweir     pEncInfo->Flags = pData->mnInfoFlags;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     return sal_True;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir /* ======================================================================= */
178cdf0e10cSrcweir 
179cdf0e10cSrcweir rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromWindowsCharset( sal_uInt8 nWinCharset )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     rtl_TextEncoding eTextEncoding;
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     switch ( nWinCharset )
184cdf0e10cSrcweir     {
185cdf0e10cSrcweir         case 0:     eTextEncoding = RTL_TEXTENCODING_MS_1252; break;    /* ANSI_CHARSET */
186cdf0e10cSrcweir         case 2:     eTextEncoding = RTL_TEXTENCODING_SYMBOL; break;     /* SYMBOL_CHARSET */
187cdf0e10cSrcweir         case 77:    eTextEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;/* MAC_CHARSET */
188cdf0e10cSrcweir         case 128:   eTextEncoding = RTL_TEXTENCODING_MS_932; break;     /* SHIFTJIS_CHARSET */
189cdf0e10cSrcweir         case 129:   eTextEncoding = RTL_TEXTENCODING_MS_949; break;     /* HANGEUL_CHARSET */
190cdf0e10cSrcweir         case 130:   eTextEncoding = RTL_TEXTENCODING_MS_1361; break;    /* JOHAB_CHARSET */
191cdf0e10cSrcweir         case 134:   eTextEncoding = RTL_TEXTENCODING_MS_936; break;     /* GB2312_CHARSET */
192cdf0e10cSrcweir         case 136:   eTextEncoding = RTL_TEXTENCODING_MS_950; break;     /* CHINESEBIG5_CHARSET */
193cdf0e10cSrcweir         case 161:   eTextEncoding = RTL_TEXTENCODING_MS_1253; break;    /* GREEK_CHARSET */
194cdf0e10cSrcweir         case 162:   eTextEncoding = RTL_TEXTENCODING_MS_1254; break;    /* TURKISH_CHARSET */
195cdf0e10cSrcweir         case 163:   eTextEncoding = RTL_TEXTENCODING_MS_1258; break;    /* VIETNAMESE_CHARSET !!! */
196cdf0e10cSrcweir         case 177:   eTextEncoding = RTL_TEXTENCODING_MS_1255; break;    /* HEBREW_CHARSET */
197cdf0e10cSrcweir         case 178:   eTextEncoding = RTL_TEXTENCODING_MS_1256; break;    /* ARABIC_CHARSET */
198cdf0e10cSrcweir         case 186:   eTextEncoding = RTL_TEXTENCODING_MS_1257; break;    /* BALTIC_CHARSET */
199cdf0e10cSrcweir         case 204:   eTextEncoding = RTL_TEXTENCODING_MS_1251; break;    /* RUSSIAN_CHARSET */
200cdf0e10cSrcweir         case 222:   eTextEncoding = RTL_TEXTENCODING_MS_874; break;     /* THAI_CHARSET */
201cdf0e10cSrcweir         case 238:   eTextEncoding = RTL_TEXTENCODING_MS_1250; break;    /* EASTEUROPE_CHARSET */
202cdf0e10cSrcweir         case 255:   eTextEncoding = RTL_TEXTENCODING_IBM_850; break;    /* OEM_CHARSET */
203cdf0e10cSrcweir         default:    eTextEncoding = RTL_TEXTENCODING_DONTKNOW; break;
204cdf0e10cSrcweir     };
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     return eTextEncoding;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir /* ----------------------------------------------------------------------- */
210cdf0e10cSrcweir 
211cdf0e10cSrcweir #if 0
212cdf0e10cSrcweir 
213cdf0e10cSrcweir rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMacTextEncoding( sal_uInt32 nMacTextEncoding )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir     rtl_TextEncoding eTextEncoding;
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     switch ( nMacTextEncoding )
218cdf0e10cSrcweir     {
219cdf0e10cSrcweir         case 0:     eTextEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;
220cdf0e10cSrcweir         case 1:     eTextEncoding = RTL_TEXTENCODING_APPLE_JAPANESE; break;
221cdf0e10cSrcweir         case 2:     eTextEncoding = RTL_TEXTENCODING_APPLE_CHINTRAD; break;
222cdf0e10cSrcweir         case 3:     eTextEncoding = RTL_TEXTENCODING_APPLE_KOREAN; break;
223cdf0e10cSrcweir         case 4:     eTextEncoding = RTL_TEXTENCODING_APPLE_ARABIC; break;
224cdf0e10cSrcweir         case 5:     eTextEncoding = RTL_TEXTENCODING_APPLE_HEBREW; break;
225cdf0e10cSrcweir         case 6:     eTextEncoding = RTL_TEXTENCODING_APPLE_GREEK; break;
226cdf0e10cSrcweir         case 7:     eTextEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break;
227cdf0e10cSrcweir         /* RIGHT-TO-LEFT SYMBOLS = 8  ??? */
228cdf0e10cSrcweir         case 9:     eTextEncoding = RTL_TEXTENCODING_APPLE_DEVANAGARI; break;
229cdf0e10cSrcweir         case 10:    eTextEncoding = RTL_TEXTENCODING_APPLE_GURMUKHI; break;
230cdf0e10cSrcweir         case 11:    eTextEncoding = RTL_TEXTENCODING_APPLE_GUJARATI; break;
231cdf0e10cSrcweir         /* MacOriya = 12 */
232cdf0e10cSrcweir         /* MacBengali = 13 */
233cdf0e10cSrcweir         /* MacTamil = 14 */
234cdf0e10cSrcweir         /* MacTelugu = 15 */
235cdf0e10cSrcweir         /* MacKannada = 16 */
236cdf0e10cSrcweir         /* MacMalayalam = 17 */
237cdf0e10cSrcweir         /* MacSinhalese = 18 */
238cdf0e10cSrcweir         /* MacBurmese = 19 */
239cdf0e10cSrcweir         /* MacKhmer = 20 */
240cdf0e10cSrcweir         case 21:    eTextEncoding = RTL_TEXTENCODING_APPLE_THAI; break;
241cdf0e10cSrcweir         /* MacLaotian = 22 */
242cdf0e10cSrcweir         /* MacGeorgian = 23 */
243cdf0e10cSrcweir         /* MacArmenian = 24 */
244cdf0e10cSrcweir         case 25:    eTextEncoding = RTL_TEXTENCODING_APPLE_CHINSIMP; break;
245cdf0e10cSrcweir         /* MacTibetan = 26 */
246cdf0e10cSrcweir         /* MacMongolian = 27 */
247cdf0e10cSrcweir         /* MacEthiopic = 28 */
248cdf0e10cSrcweir         case 29:    eTextEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break;     /* MacCentralEurRoman */
249cdf0e10cSrcweir         /* MacVietnamese = 30 */
250cdf0e10cSrcweir         /* MacExtArabic = 31 */
251cdf0e10cSrcweir         case 32:    eTextEncoding = RTL_TEXTENCODING_SYMBOL; break;
252cdf0e10cSrcweir         case 33:    eTextEncoding = RTL_TEXTENCODING_SYMBOL; break;     /* MacSymbol */
253cdf0e10cSrcweir         case 34:    eTextEncoding = RTL_TEXTENCODING_SYMBOL; break;     /* MacDingbats */
254cdf0e10cSrcweir         case 35:    eTextEncoding = RTL_TEXTENCODING_APPLE_TURKISH; break;      /* MacTurkish */
255cdf0e10cSrcweir         case 36:    eTextEncoding = RTL_TEXTENCODING_APPLE_CROATIAN; break;     /* MacCroatian */
256cdf0e10cSrcweir         case 37:    eTextEncoding = RTL_TEXTENCODING_APPLE_ICELAND; break;      /* MacIcelandic */
257cdf0e10cSrcweir         case 38:    eTextEncoding = RTL_TEXTENCODING_APPLE_ROMANIAN; break;     /* MacRomanian */
258cdf0e10cSrcweir         /* MacCeltic = 39 */
259cdf0e10cSrcweir         /* MacGaelic = 40 */
260cdf0e10cSrcweir         /* Beginning in Mac OS 8.5, the set of Mac OS script codes has been */
261cdf0e10cSrcweir         /* extended for some Mac OS components to include Unicode. Some of */
262cdf0e10cSrcweir         /* these components have only 7 bits available for script code, so */
263cdf0e10cSrcweir         /* kTextEncodingUnicodeDefault cannot be used to indicate Unicode. */
264cdf0e10cSrcweir         /* Instead, the following meta-value is used to indicate Unicode */
265cdf0e10cSrcweir         /* handled as a special Mac OS script code; TEC handles this value */
266cdf0e10cSrcweir         /* like kTextEncodingUnicodeDefault. */
267cdf0e10cSrcweir         /* The following use script code 4, smArabic */
268cdf0e10cSrcweir         case 0x08C: eTextEncoding = RTL_TEXTENCODING_APPLE_FARSI; break;        /* MacFarsi */
269cdf0e10cSrcweir         /* The following use script code 7, smCyrillic */
270cdf0e10cSrcweir         case 0x098: eTextEncoding = RTL_TEXTENCODING_APPLE_UKRAINIAN; break;    /* MacUkrainian */
271cdf0e10cSrcweir         /* The following use script code 28, smEthiopic */
272cdf0e10cSrcweir         /* MacInuit = 0xEC */
273cdf0e10cSrcweir         /* The following use script code 32, smUninterp */
274cdf0e10cSrcweir         case 0x0FC: eTextEncoding = RTL_TEXTENCODING_SYMBOL; break;       /* MacVT100 - VT100/102 font */
275cdf0e10cSrcweir         /* Special Mac OS encodings */
276cdf0e10cSrcweir         /* MacHFS = 0xFF */ /* metavalue. */
277cdf0e10cSrcweir         /* Unicode & ISO UCS encodings begin at 0x100 */
278cdf0e10cSrcweir         case 0x100: eTextEncoding = RTL_TEXTENCODING_UNICODE; break;    /* UnicodeDefault */
279cdf0e10cSrcweir         case 0x101: eTextEncoding = RTL_TEXTENCODING_UNICODE; break;    /* UnicodeV1_1 / ISO10646_1993 */
280cdf0e10cSrcweir         case 0x103: eTextEncoding = RTL_TEXTENCODING_UNICODE; break;    /* UnicodeV2_1 - new location for Korean Hangul / UnicodeV2_1 */
281cdf0e10cSrcweir         /* ISO 8-bit and 7-bit encodings begin at 0x200 */
282cdf0e10cSrcweir         case 0x201: eTextEncoding = RTL_TEXTENCODING_ISO_8859_1; break; /* ISOLatin1 - ISO 8859-1 */
283cdf0e10cSrcweir         case 0x202: eTextEncoding = RTL_TEXTENCODING_ISO_8859_2; break; /* ISOLatin2 - ISO 8859-2 */
284cdf0e10cSrcweir         case 0x203: eTextEncoding = RTL_TEXTENCODING_ISO_8859_3; break; /* ISOLatin3 - ISO 8859-3 */
285cdf0e10cSrcweir         case 0x204: eTextEncoding = RTL_TEXTENCODING_ISO_8859_4; break; /* ISOLatin4 - ISO 8859-4 */
286cdf0e10cSrcweir         case 0x205: eTextEncoding = RTL_TEXTENCODING_ISO_8859_5; break; /* ISOLatinCyrillic - ISO 8859-5 */
287cdf0e10cSrcweir         case 0x206: eTextEncoding = RTL_TEXTENCODING_ISO_8859_6; break; /* ISOLatinArabic - ISO 8859-6, = ASMO 708, =DOS CP 708 */
288cdf0e10cSrcweir         case 0x207: eTextEncoding = RTL_TEXTENCODING_ISO_8859_7; break; /* ISOLatinGreek - ISO 8859-7 */
289cdf0e10cSrcweir         case 0x208: eTextEncoding = RTL_TEXTENCODING_ISO_8859_8; break; /* ISOLatinHebrew - ISO 8859-8 */
290cdf0e10cSrcweir         case 0x209: eTextEncoding = RTL_TEXTENCODING_ISO_8859_9; break; /* ISOLatin5 - ISO 8859-9 */
291cdf0e10cSrcweir         /* MS-DOS & Windows encodings begin at 0x400 */
292cdf0e10cSrcweir         case 0x400: eTextEncoding = RTL_TEXTENCODING_IBM_437; break;    /* DOSLatinUS - code page 437 */
293cdf0e10cSrcweir         case 0x405: eTextEncoding = RTL_TEXTENCODING_IBM_737; break;    /* DOSGreek - code page 737 (formerly 437G) */
294cdf0e10cSrcweir         case 0x406: eTextEncoding = RTL_TEXTENCODING_IBM_775; break;    /* DOSBalticRim - code page 775 */
295cdf0e10cSrcweir         case 0x410: eTextEncoding = RTL_TEXTENCODING_IBM_850; break;    /* DOSLatin1 - code page 850, "Multilingual" */
296cdf0e10cSrcweir /* !!!       case 0x411: eTextEncoding = RTL_TEXTENCODING_IBM_851; break; */    /* DOSGreek1 - code page 851 */
297cdf0e10cSrcweir         case 0x412: eTextEncoding = RTL_TEXTENCODING_IBM_852; break;    /* DOSLatin2 - code page 852, Slavic */
298cdf0e10cSrcweir         case 0x413: eTextEncoding = RTL_TEXTENCODING_IBM_855; break;    /* DOSCyrillic - code page 855, IBM Cyrillic */
299cdf0e10cSrcweir         case 0x414: eTextEncoding = RTL_TEXTENCODING_IBM_857; break;    /* DOSTurkish - code page 857, IBM Turkish */
300cdf0e10cSrcweir         case 0x415: eTextEncoding = RTL_TEXTENCODING_IBM_860; break;    /* DOSPortuguese - code page 860 */
301cdf0e10cSrcweir         case 0x416: eTextEncoding = RTL_TEXTENCODING_IBM_861; break;    /* DOSIcelandic - code page 861 */
302cdf0e10cSrcweir         case 0x417: eTextEncoding = RTL_TEXTENCODING_IBM_862; break;    /* DOSHebrew - code page 862 */
303cdf0e10cSrcweir         case 0x418: eTextEncoding = RTL_TEXTENCODING_IBM_863; break;    /* DOSCanadianFrench - code page 863 */
304cdf0e10cSrcweir         case 0x419: eTextEncoding = RTL_TEXTENCODING_IBM_864; break;    /* DOSArabic - code page 864 */
305cdf0e10cSrcweir         case 0x41A: eTextEncoding = RTL_TEXTENCODING_IBM_865; break;    /* DOSNordic - code page 865 */
306cdf0e10cSrcweir         case 0x41B: eTextEncoding = RTL_TEXTENCODING_IBM_866; break;    /* DOSRussian - code page 866 */
307cdf0e10cSrcweir         case 0x41C: eTextEncoding = RTL_TEXTENCODING_IBM_869; break;    /* DOSGreek2 - code page 869, IBM Modern Greek */
308cdf0e10cSrcweir         case 0x41D: eTextEncoding = RTL_TEXTENCODING_MS_874; break;     /* DOSThai - code page 874, also for Windows */
309cdf0e10cSrcweir         case 0x420: eTextEncoding = RTL_TEXTENCODING_MS_932; break;     /* DOSJapanese - code page 932, also for Windows */
310cdf0e10cSrcweir         case 0x421: eTextEncoding = RTL_TEXTENCODING_MS_936; break;     /* DOSChineseSimplif - code page 936, also for Windows */
311cdf0e10cSrcweir         case 0x422: eTextEncoding = RTL_TEXTENCODING_MS_949; break;     /* DOSKorean - code page 949, also for Windows;Unified Hangul */
312cdf0e10cSrcweir         case 0x423: eTextEncoding = RTL_TEXTENCODING_MS_950; break;     /* DOSChineseTrad - code page 950, also for Windows */
313cdf0e10cSrcweir         case 0x500: eTextEncoding = RTL_TEXTENCODING_MS_1252; break;    /* WindowsLatin1 / WindowsANSI - code page 1252 */
314cdf0e10cSrcweir         case 0x501: eTextEncoding = RTL_TEXTENCODING_MS_1250; break;    /* WindowsLatin2 - code page 1250, Central Europe */
315cdf0e10cSrcweir         case 0x502: eTextEncoding = RTL_TEXTENCODING_MS_1251; break;    /* WindowsCyrillic - code page 1251, Slavic Cyrillic */
316cdf0e10cSrcweir         case 0x503: eTextEncoding = RTL_TEXTENCODING_MS_1253; break;    /* WindowsGreek - code page 1253 */
317cdf0e10cSrcweir         case 0x504: eTextEncoding = RTL_TEXTENCODING_MS_1254; break;    /* WindowsLatin5 - code page 1254, Turkish */
318cdf0e10cSrcweir         case 0x505: eTextEncoding = RTL_TEXTENCODING_MS_1255; break;    /* WindowsHebrew - code page 1255 */
319cdf0e10cSrcweir         case 0x506: eTextEncoding = RTL_TEXTENCODING_MS_1256; break;    /* WindowsArabic - code page 1256 */
320cdf0e10cSrcweir         case 0x507: eTextEncoding = RTL_TEXTENCODING_MS_1257; break;    /* WindowsBalticRim - code page 1257 */
321cdf0e10cSrcweir         case 0x508: eTextEncoding = RTL_TEXTENCODING_MS_1258; break;    /* WindowsVietnamese - code page 1258 */
322cdf0e10cSrcweir         case 0x510: eTextEncoding = RTL_TEXTENCODING_MS_1361; break;    /* WindowsKoreanJohab - code page 1361, for Windows NT */
323cdf0e10cSrcweir         /* Various national standards begin at 0x600 */
324cdf0e10cSrcweir         case 0x600: eTextEncoding = RTL_TEXTENCODING_ASCII_US; break;    /* US_ASCII */
325cdf0e10cSrcweir         case 0x620: eTextEncoding = RTL_TEXTENCODING_JIS_X_0201; break;  /* JIS_X0201_76 */
326cdf0e10cSrcweir         case 0x621: eTextEncoding = RTL_TEXTENCODING_JIS_X_0208; break;  /* JIS_X0208_83 */
327cdf0e10cSrcweir         case 0x622: eTextEncoding = RTL_TEXTENCODING_JIS_X_0208; break;  /* JIS_X0208_90 */
328cdf0e10cSrcweir         case 0x623: eTextEncoding = RTL_TEXTENCODING_JIS_X_0212; break;  /* JIS_X0212_90 */
329cdf0e10cSrcweir         /* !!! JIS_C6226_78 = 0x624 */
330cdf0e10cSrcweir         /* !!! GB_2312_80 = 0x630 */
331cdf0e10cSrcweir         /* !!! GBK_95 = 0x631 */ /* annex to GB 13000-93; for Windows 95 */
332cdf0e10cSrcweir //        case 0x640: eTextEncoding = RTL_TEXTENCODING_KSC_5601_1987; break; /* KSC_5601_87 */ /* same as KSC 5601-92 without Johab annex */
333cdf0e10cSrcweir //        case 0x641: eTextEncoding = RTL_TEXTENCODING_KSC_5601_1992; break; /* KSC 5601-92 Johab annex */
334cdf0e10cSrcweir         /* !!! CNS_11643_92_P1 = 0x651 */ /* CNS 11643-1992 plane 1 */
335cdf0e10cSrcweir         /* !!! CNS_11643_92_P2 = 0x652 */ /* CNS 11643-1992 plane 2 */
336cdf0e10cSrcweir         /* !!! CNS_11643_92_P3 = 0x653 */ /* CNS 11643-1992 plane 3 (11643-1986 plane 14) */
337cdf0e10cSrcweir         /* ISO 2022 collections begin at 0x800 */
338cdf0e10cSrcweir         case 0x820: eTextEncoding = RTL_TEXTENCODING_ISO_2022_JP; break;    /* ISO_2022_JP */
339cdf0e10cSrcweir         case 0x821: eTextEncoding = RTL_TEXTENCODING_ISO_2022_JP; break;    /* ISO_2022_JP_2 */
340cdf0e10cSrcweir         case 0x830: eTextEncoding = RTL_TEXTENCODING_ISO_2022_CN; break;    /* ISO_2022_CN */
341cdf0e10cSrcweir         case 0x831: eTextEncoding = RTL_TEXTENCODING_ISO_2022_CN; break;    /* ISO_2022_CN_EXT */
342cdf0e10cSrcweir         /* !!! ISO_2022_KR = 0x840 */
343cdf0e10cSrcweir         /* EUC collections begin at 0x900 */
344cdf0e10cSrcweir         case 0x920: eTextEncoding = RTL_TEXTENCODING_EUC_JP; break;    /* EUC_JP - ISO 646,1-byte Katakana,JIS 208,JIS 212 */
345cdf0e10cSrcweir         case 0x930: eTextEncoding = RTL_TEXTENCODING_EUC_CN; break;    /* EUC_CN - ISO 646, GB 2312-80 */
346cdf0e10cSrcweir         case 0x931: eTextEncoding = RTL_TEXTENCODING_EUC_TW; break;    /* EUC_TW - ISO 646, CNS 11643-1992 Planes 1-16 */
347cdf0e10cSrcweir         case 0x940: eTextEncoding = RTL_TEXTENCODING_EUC_KR; break;    /* EUC_KR - ISO 646, KS C 5601-1987 */
348cdf0e10cSrcweir         /* Miscellaneous standards begin at 0xA00 */
349cdf0e10cSrcweir         case 0xA01: eTextEncoding = RTL_TEXTENCODING_SHIFT_JIS; break; /* ShiftJIS - plain Shift-JIS */
350cdf0e10cSrcweir         case 0xA02: eTextEncoding = RTL_TEXTENCODING_KOI8_R; break;    /* KOI8_R - Russian Internet standard */
351cdf0e10cSrcweir         case 0xA03: eTextEncoding = RTL_TEXTENCODING_BIG5; break;      /* Big5 - Big-5 */
352cdf0e10cSrcweir         /* !!! MacRomanLatin1 = 0xA04 */ /* Mac OS Roman permuted to align with 8859-1 */
353cdf0e10cSrcweir         /* !!! HZ_GB_2312 = 0xA05 */ /* HZ (RFC 1842, for Chinese mail & news) */
354cdf0e10cSrcweir         /* Other platform encodings */
355cdf0e10cSrcweir         /* !!! NextStepLatin = 0xB01 */ /* NextStep encoding */
356cdf0e10cSrcweir         /* EBCDIC & IBM host encodings begin at 0xC00 */
357cdf0e10cSrcweir         /* !!! EBCDIC_US = 0xC01 */ /* basic EBCDIC-US */
358cdf0e10cSrcweir         /* !!! EBCDIC_CP037 = 0xC02 */ /* code page 037, extended EBCDIC-US Latin1 */
359cdf0e10cSrcweir         /* Special value */
360cdf0e10cSrcweir         /* MultiRun = 0xFFF */ /* Multiple encoded text, external run info */
361cdf0e10cSrcweir         default:    eTextEncoding = RTL_TEXTENCODING_DONTKNOW; break;
362cdf0e10cSrcweir     };
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     return eTextEncoding;
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir #endif
368cdf0e10cSrcweir 
369cdf0e10cSrcweir /* ----------------------------------------------------------------------- */
370cdf0e10cSrcweir 
371cdf0e10cSrcweir rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const sal_Char* pUnixCharset )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     /* See <ftp://ftp.x.org/pub/DOCS/registry>, section 14 ("Font Charset
374cdf0e10cSrcweir      * (Registry and Encoding) Names").
375cdf0e10cSrcweir      */
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     /* All Identifiers in the tables are lower case The function search */
378cdf0e10cSrcweir     /* for the first matching string in the tables. */
379cdf0e10cSrcweir     /* Sort order: unique (first 14, than 1), important */
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetISOTab[] =
382cdf0e10cSrcweir     {
383cdf0e10cSrcweir         { "15", RTL_TEXTENCODING_ISO_8859_15 },
384cdf0e10cSrcweir         { "14", RTL_TEXTENCODING_ISO_8859_14 },
385cdf0e10cSrcweir         { "13", RTL_TEXTENCODING_ISO_8859_13 },
386cdf0e10cSrcweir         { "11", RTL_TEXTENCODING_TIS_620 },
387cdf0e10cSrcweir         { "10", RTL_TEXTENCODING_ISO_8859_10 },
388cdf0e10cSrcweir         { "1", RTL_TEXTENCODING_ISO_8859_1 },
389cdf0e10cSrcweir         { "2", RTL_TEXTENCODING_ISO_8859_2 },
390cdf0e10cSrcweir         { "3", RTL_TEXTENCODING_ISO_8859_3 },
391cdf0e10cSrcweir         { "4", RTL_TEXTENCODING_ISO_8859_4 },
392cdf0e10cSrcweir         { "5", RTL_TEXTENCODING_ISO_8859_5 },
393cdf0e10cSrcweir         { "6", RTL_TEXTENCODING_ISO_8859_6 },
394cdf0e10cSrcweir         { "7", RTL_TEXTENCODING_ISO_8859_7 },
395cdf0e10cSrcweir         { "8", RTL_TEXTENCODING_ISO_8859_8 },
396cdf0e10cSrcweir         { "9", RTL_TEXTENCODING_ISO_8859_9 },
397cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
398cdf0e10cSrcweir     };
399cdf0e10cSrcweir 
400cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetADOBETab[] =
401cdf0e10cSrcweir     {
402cdf0e10cSrcweir         { "fontspecific", RTL_TEXTENCODING_SYMBOL },
403cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
404cdf0e10cSrcweir     };
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetMSTab[] =
407cdf0e10cSrcweir     {
408cdf0e10cSrcweir         { "1252", RTL_TEXTENCODING_MS_1252 },
409cdf0e10cSrcweir         { "1250", RTL_TEXTENCODING_MS_1250 },
410cdf0e10cSrcweir         { "1251", RTL_TEXTENCODING_MS_1251 },
411cdf0e10cSrcweir         { "1253", RTL_TEXTENCODING_MS_1253 },
412cdf0e10cSrcweir         { "1254", RTL_TEXTENCODING_MS_1254 },
413cdf0e10cSrcweir         { "1255", RTL_TEXTENCODING_MS_1255 },
414cdf0e10cSrcweir         { "1256", RTL_TEXTENCODING_MS_1256 },
415cdf0e10cSrcweir         { "1257", RTL_TEXTENCODING_MS_1257 },
416cdf0e10cSrcweir         { "1258", RTL_TEXTENCODING_MS_1258 },
417cdf0e10cSrcweir         { "932", RTL_TEXTENCODING_MS_932 },
418cdf0e10cSrcweir         { "936", RTL_TEXTENCODING_MS_936 },
419cdf0e10cSrcweir         { "949", RTL_TEXTENCODING_MS_949 },
420cdf0e10cSrcweir         { "950", RTL_TEXTENCODING_MS_950 },
421cdf0e10cSrcweir         { "1361", RTL_TEXTENCODING_MS_1361 },
422cdf0e10cSrcweir         { "cp1252", RTL_TEXTENCODING_MS_1252 },
423cdf0e10cSrcweir         { "cp1250", RTL_TEXTENCODING_MS_1250 },
424cdf0e10cSrcweir         { "cp1251", RTL_TEXTENCODING_MS_1251 },
425cdf0e10cSrcweir         { "cp1253", RTL_TEXTENCODING_MS_1253 },
426cdf0e10cSrcweir         { "cp1254", RTL_TEXTENCODING_MS_1254 },
427cdf0e10cSrcweir         { "cp1255", RTL_TEXTENCODING_MS_1255 },
428cdf0e10cSrcweir         { "cp1256", RTL_TEXTENCODING_MS_1256 },
429cdf0e10cSrcweir         { "cp1257", RTL_TEXTENCODING_MS_1257 },
430cdf0e10cSrcweir         { "cp1258", RTL_TEXTENCODING_MS_1258 },
431cdf0e10cSrcweir         { "cp932", RTL_TEXTENCODING_MS_932 },
432cdf0e10cSrcweir         { "cp936", RTL_TEXTENCODING_MS_936 },
433cdf0e10cSrcweir         { "cp949", RTL_TEXTENCODING_MS_949 },
434cdf0e10cSrcweir         { "cp950", RTL_TEXTENCODING_MS_950 },
435cdf0e10cSrcweir         { "cp1361", RTL_TEXTENCODING_MS_1361 },
436cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
437cdf0e10cSrcweir     };
438cdf0e10cSrcweir 
439cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetIBMTab[] =
440cdf0e10cSrcweir     {
441cdf0e10cSrcweir         { "437", RTL_TEXTENCODING_IBM_437 },
442cdf0e10cSrcweir         { "850", RTL_TEXTENCODING_IBM_850 },
443cdf0e10cSrcweir         { "860", RTL_TEXTENCODING_IBM_860 },
444cdf0e10cSrcweir         { "861", RTL_TEXTENCODING_IBM_861 },
445cdf0e10cSrcweir         { "863", RTL_TEXTENCODING_IBM_863 },
446cdf0e10cSrcweir         { "865", RTL_TEXTENCODING_IBM_865 },
447cdf0e10cSrcweir         { "737", RTL_TEXTENCODING_IBM_737 },
448cdf0e10cSrcweir         { "775", RTL_TEXTENCODING_IBM_775 },
449cdf0e10cSrcweir         { "852", RTL_TEXTENCODING_IBM_852 },
450cdf0e10cSrcweir         { "855", RTL_TEXTENCODING_IBM_855 },
451cdf0e10cSrcweir         { "857", RTL_TEXTENCODING_IBM_857 },
452cdf0e10cSrcweir         { "862", RTL_TEXTENCODING_IBM_862 },
453cdf0e10cSrcweir         { "864", RTL_TEXTENCODING_IBM_864 },
454cdf0e10cSrcweir         { "866", RTL_TEXTENCODING_IBM_866 },
455cdf0e10cSrcweir         { "869", RTL_TEXTENCODING_IBM_869 },
456cdf0e10cSrcweir         { "874", RTL_TEXTENCODING_MS_874 },
457cdf0e10cSrcweir         { "1004", RTL_TEXTENCODING_MS_1252 },
458cdf0e10cSrcweir         { "65400", RTL_TEXTENCODING_SYMBOL },
459cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
460cdf0e10cSrcweir     };
461cdf0e10cSrcweir 
462cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetKOI8Tab[] =
463cdf0e10cSrcweir     {
464cdf0e10cSrcweir         { "r", RTL_TEXTENCODING_KOI8_R },
465cdf0e10cSrcweir         { "u", RTL_TEXTENCODING_KOI8_U },
466cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
467cdf0e10cSrcweir     };
468cdf0e10cSrcweir 
469cdf0e10cSrcweir     static ImplStrCharsetDef aUnixCharsetJISX0208Tab[] =
470cdf0e10cSrcweir     {
471cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_JIS_X_0208 }
472cdf0e10cSrcweir     };
473cdf0e10cSrcweir 
474cdf0e10cSrcweir     static ImplStrCharsetDef aUnixCharsetJISX0201Tab[] =
475cdf0e10cSrcweir     {
476cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_JIS_X_0201 }
477cdf0e10cSrcweir     };
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     static ImplStrCharsetDef aUnixCharsetJISX0212Tab[] =
480cdf0e10cSrcweir     {
481cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_JIS_X_0212 }
482cdf0e10cSrcweir     };
483cdf0e10cSrcweir 
484cdf0e10cSrcweir     static ImplStrCharsetDef aUnixCharsetGBTab[] =
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_GB_2312 }
487cdf0e10cSrcweir     };
488cdf0e10cSrcweir 
489cdf0e10cSrcweir     static ImplStrCharsetDef aUnixCharsetGBKTab[] =
490cdf0e10cSrcweir     {
491cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_GBK }
492cdf0e10cSrcweir     };
493cdf0e10cSrcweir 
494cdf0e10cSrcweir     static ImplStrCharsetDef aUnixCharsetBIG5Tab[] =
495cdf0e10cSrcweir     {
496cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_BIG5 }
497cdf0e10cSrcweir     };
498cdf0e10cSrcweir 
499cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetKSC56011987Tab[] =
500cdf0e10cSrcweir     {
501cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_EUC_KR }
502cdf0e10cSrcweir     };
503cdf0e10cSrcweir 
504cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetKSC56011992Tab[] =
505cdf0e10cSrcweir     {
506cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_MS_1361 }
507cdf0e10cSrcweir     };
508cdf0e10cSrcweir 
509cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetISO10646Tab[] =
510cdf0e10cSrcweir     {
511cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_UNICODE }
512cdf0e10cSrcweir     };
513cdf0e10cSrcweir 
514cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetUNICODETab[] =
515cdf0e10cSrcweir     {
516cdf0e10cSrcweir /* Currently every Unicode Encoding is for us Unicode */
517cdf0e10cSrcweir /*        { "fontspecific", RTL_TEXTENCODING_UNICODE }, */
518cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_UNICODE }
519cdf0e10cSrcweir     };
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetSymbolTab[] =
522cdf0e10cSrcweir     {
523cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_SYMBOL }
524cdf0e10cSrcweir     };
525cdf0e10cSrcweir 
526cdf0e10cSrcweir     /* See <http://cvs.freedesktop.org/xorg/xc/fonts/encodings/iso8859-11.enc?
527cdf0e10cSrcweir        rev=1.1.1.1>: */
528cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetTIS620Tab[] =
529cdf0e10cSrcweir     {
530cdf0e10cSrcweir         { "0", RTL_TEXTENCODING_TIS_620 },
531cdf0e10cSrcweir         { "2529", RTL_TEXTENCODING_TIS_620 },
532cdf0e10cSrcweir         { "2533", RTL_TEXTENCODING_TIS_620 },
533cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
534cdf0e10cSrcweir     };
535cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetTIS6202529Tab[] =
536cdf0e10cSrcweir     {
537cdf0e10cSrcweir         { "1", RTL_TEXTENCODING_TIS_620 },
538cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
539cdf0e10cSrcweir     };
540cdf0e10cSrcweir     static ImplStrCharsetDef const aUnixCharsetTIS6202533Tab[] =
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         { "0", RTL_TEXTENCODING_TIS_620 },
543cdf0e10cSrcweir         { "1", RTL_TEXTENCODING_TIS_620 },
544cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
545cdf0e10cSrcweir     };
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     static ImplStrFirstPartCharsetDef const aUnixCharsetFirstPartTab[] =
548cdf0e10cSrcweir     {
549cdf0e10cSrcweir         { "iso8859", aUnixCharsetISOTab },
550cdf0e10cSrcweir         { "adobe", aUnixCharsetADOBETab },
551cdf0e10cSrcweir         { "ansi", aUnixCharsetMSTab },
552cdf0e10cSrcweir         { "microsoft", aUnixCharsetMSTab },
553cdf0e10cSrcweir         { "ibm", aUnixCharsetIBMTab },
554cdf0e10cSrcweir         { "koi8", aUnixCharsetKOI8Tab },
555cdf0e10cSrcweir         { "jisx0208", aUnixCharsetJISX0208Tab },
556cdf0e10cSrcweir         { "jisx0208.1983", aUnixCharsetJISX0208Tab },
557cdf0e10cSrcweir         { "jisx0201", aUnixCharsetJISX0201Tab },
558cdf0e10cSrcweir         { "jisx0201.1976", aUnixCharsetJISX0201Tab },
559cdf0e10cSrcweir         { "jisx0212", aUnixCharsetJISX0212Tab },
560cdf0e10cSrcweir         { "jisx0212.1990", aUnixCharsetJISX0212Tab },
561cdf0e10cSrcweir         { "gb2312", aUnixCharsetGBTab },
562cdf0e10cSrcweir         { "gbk", aUnixCharsetGBKTab },
563cdf0e10cSrcweir         { "big5", aUnixCharsetBIG5Tab },
564cdf0e10cSrcweir         { "iso10646", aUnixCharsetISO10646Tab },
565cdf0e10cSrcweir /*      { "unicode", aUnixCharsetUNICODETab }, */ /* fonts contain only default chars */
566cdf0e10cSrcweir         { "sunolcursor", aUnixCharsetSymbolTab },
567cdf0e10cSrcweir         { "sunolglyph", aUnixCharsetSymbolTab },
568cdf0e10cSrcweir         { "iso10646", aUnixCharsetUNICODETab },
569cdf0e10cSrcweir         { "ksc5601.1987", aUnixCharsetKSC56011987Tab },
570cdf0e10cSrcweir         { "ksc5601.1992", aUnixCharsetKSC56011992Tab },
571cdf0e10cSrcweir         { "tis620.2529", aUnixCharsetTIS6202529Tab },
572cdf0e10cSrcweir         { "tis620.2533", aUnixCharsetTIS6202533Tab },
573cdf0e10cSrcweir         { "tis620", aUnixCharsetTIS620Tab },
574cdf0e10cSrcweir /*        { "sunudcja.1997",  },        */
575cdf0e10cSrcweir /*        { "sunudcko.1997",  },        */
576cdf0e10cSrcweir /*        { "sunudczh.1997",  },        */
577cdf0e10cSrcweir /*        { "sunudczhtw.1997",  },      */
578cdf0e10cSrcweir         { NULL, NULL }
579cdf0e10cSrcweir     };
580cdf0e10cSrcweir 
581cdf0e10cSrcweir     rtl_TextEncoding    eEncoding = RTL_TEXTENCODING_DONTKNOW;
582cdf0e10cSrcweir     sal_Char*           pBuf;
583cdf0e10cSrcweir     sal_Char*           pTempBuf;
584cdf0e10cSrcweir     sal_uInt32          nBufLen = strlen( pUnixCharset )+1;
585cdf0e10cSrcweir     const sal_Char*     pFirstPart;
586cdf0e10cSrcweir     const sal_Char*     pSecondPart;
587cdf0e10cSrcweir 
588cdf0e10cSrcweir     /* Alloc Buffer and map to lower case */
589cdf0e10cSrcweir     pBuf = (char*)rtl_allocateMemory( nBufLen );
590cdf0e10cSrcweir     Impl_toAsciiLower( pUnixCharset, pBuf );
591cdf0e10cSrcweir 
592cdf0e10cSrcweir     /* Search FirstPart */
593cdf0e10cSrcweir     pFirstPart = pBuf;
594cdf0e10cSrcweir     pSecondPart = NULL;
595cdf0e10cSrcweir     pTempBuf = pBuf;
596cdf0e10cSrcweir     while ( *pTempBuf )
597cdf0e10cSrcweir     {
598cdf0e10cSrcweir         if ( *pTempBuf == '-' )
599cdf0e10cSrcweir         {
600cdf0e10cSrcweir             *pTempBuf = '\0';
601cdf0e10cSrcweir             pSecondPart = pTempBuf+1;
602cdf0e10cSrcweir             break;
603cdf0e10cSrcweir         }
604cdf0e10cSrcweir 
605cdf0e10cSrcweir         pTempBuf++;
606cdf0e10cSrcweir     }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir     /* Parttrenner gefunden */
609cdf0e10cSrcweir     if ( pSecondPart )
610cdf0e10cSrcweir     {
611cdf0e10cSrcweir         /* Search for the part tab */
612cdf0e10cSrcweir         const ImplStrFirstPartCharsetDef* pFirstPartData = aUnixCharsetFirstPartTab;
613cdf0e10cSrcweir         while ( pFirstPartData->mpCharsetStr )
614cdf0e10cSrcweir         {
615cdf0e10cSrcweir             if ( Impl_matchString( pFirstPart, pFirstPartData->mpCharsetStr ) )
616cdf0e10cSrcweir             {
617cdf0e10cSrcweir                 /* Search for the charset in the second part tab */
618cdf0e10cSrcweir                 const ImplStrCharsetDef* pData = pFirstPartData->mpSecondPartTab;
619cdf0e10cSrcweir                 while ( pData->mpCharsetStr )
620cdf0e10cSrcweir                 {
621cdf0e10cSrcweir                     if ( Impl_matchString( pSecondPart, pData->mpCharsetStr ) )
622cdf0e10cSrcweir                     {
623cdf0e10cSrcweir                         eEncoding = pData->meTextEncoding;
624cdf0e10cSrcweir                         break;
625cdf0e10cSrcweir                     }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir                     pData++;
628cdf0e10cSrcweir                 }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir                 /* use default encoding for first part */
631cdf0e10cSrcweir                 eEncoding = pData->meTextEncoding;
632cdf0e10cSrcweir                 break;
633cdf0e10cSrcweir             }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir             pFirstPartData++;
636cdf0e10cSrcweir         }
637cdf0e10cSrcweir     }
638cdf0e10cSrcweir 
639cdf0e10cSrcweir     rtl_freeMemory( pBuf );
640cdf0e10cSrcweir 
641cdf0e10cSrcweir     return eEncoding;
642cdf0e10cSrcweir }
643cdf0e10cSrcweir 
644cdf0e10cSrcweir /* ----------------------------------------------------------------------- */
645cdf0e10cSrcweir 
646cdf0e10cSrcweir rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const sal_Char* pMimeCharset )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir     /* All Identifiers are in lower case and contain only alphanumeric */
649cdf0e10cSrcweir     /* characters. The function search for the first equal string in */
650cdf0e10cSrcweir     /* the table. In this table are only the most used mime types. */
651cdf0e10cSrcweir     /* Sort order: important */
652cdf0e10cSrcweir     static ImplStrCharsetDef const aVIPMimeCharsetTab[] =
653cdf0e10cSrcweir     {
654cdf0e10cSrcweir         { "usascii", RTL_TEXTENCODING_ASCII_US },
655cdf0e10cSrcweir         { "utf8", RTL_TEXTENCODING_UTF8 },
656cdf0e10cSrcweir         { "utf7", RTL_TEXTENCODING_UTF7 },
657cdf0e10cSrcweir         { "iso88591", RTL_TEXTENCODING_ISO_8859_1 },
658cdf0e10cSrcweir         { "iso88592", RTL_TEXTENCODING_ISO_8859_2 },
659cdf0e10cSrcweir         { "iso88593", RTL_TEXTENCODING_ISO_8859_3 },
660cdf0e10cSrcweir         { "iso88594", RTL_TEXTENCODING_ISO_8859_4 },
661cdf0e10cSrcweir         { "iso88595", RTL_TEXTENCODING_ISO_8859_5 },
662cdf0e10cSrcweir         { "iso88596", RTL_TEXTENCODING_ISO_8859_6 },
663cdf0e10cSrcweir         { "iso88597", RTL_TEXTENCODING_ISO_8859_7 },
664cdf0e10cSrcweir         { "iso88598", RTL_TEXTENCODING_ISO_8859_8 },
665cdf0e10cSrcweir         { "iso88599", RTL_TEXTENCODING_ISO_8859_9 },
666cdf0e10cSrcweir         { "iso885910", RTL_TEXTENCODING_ISO_8859_10 },
667cdf0e10cSrcweir         { "iso885913", RTL_TEXTENCODING_ISO_8859_13 },
668cdf0e10cSrcweir         { "iso885914", RTL_TEXTENCODING_ISO_8859_14 },
669cdf0e10cSrcweir         { "iso885915", RTL_TEXTENCODING_ISO_8859_15 },
670cdf0e10cSrcweir         { "iso2022jp", RTL_TEXTENCODING_ISO_2022_JP },
671cdf0e10cSrcweir         { "iso2022jp2", RTL_TEXTENCODING_ISO_2022_JP },
672cdf0e10cSrcweir         { "iso2022cn", RTL_TEXTENCODING_ISO_2022_CN },
673cdf0e10cSrcweir         { "iso2022cnext", RTL_TEXTENCODING_ISO_2022_CN },
674cdf0e10cSrcweir         { "iso2022kr", RTL_TEXTENCODING_ISO_2022_KR },
675cdf0e10cSrcweir         { "eucjp", RTL_TEXTENCODING_EUC_JP },
676cdf0e10cSrcweir         { "shiftjis", RTL_TEXTENCODING_SHIFT_JIS },
677cdf0e10cSrcweir         { "mskanji", RTL_TEXTENCODING_MS_932 },
678cdf0e10cSrcweir         { "gb2312", RTL_TEXTENCODING_GB_2312 },
679cdf0e10cSrcweir         { "cngb", RTL_TEXTENCODING_GB_2312 },
680cdf0e10cSrcweir         { "big5", RTL_TEXTENCODING_BIG5 },
681cdf0e10cSrcweir         { "cnbig5", RTL_TEXTENCODING_BIG5 },
682cdf0e10cSrcweir         { "cngb12345", RTL_TEXTENCODING_GBT_12345 },
683cdf0e10cSrcweir         { "euckr", RTL_TEXTENCODING_EUC_KR },
684cdf0e10cSrcweir         { "koi8r", RTL_TEXTENCODING_KOI8_R },
685cdf0e10cSrcweir         { "windows1252", RTL_TEXTENCODING_MS_1252 },
686cdf0e10cSrcweir         { "windows1250", RTL_TEXTENCODING_MS_1250 },
687cdf0e10cSrcweir         { "windows1251", RTL_TEXTENCODING_MS_1251 },
688cdf0e10cSrcweir         { "windows1253", RTL_TEXTENCODING_MS_1253 },
689cdf0e10cSrcweir         { "windows1254", RTL_TEXTENCODING_MS_1254 },
690cdf0e10cSrcweir         { "windows1255", RTL_TEXTENCODING_MS_1255 },
691cdf0e10cSrcweir         { "windows1256", RTL_TEXTENCODING_MS_1256 },
692cdf0e10cSrcweir         { "windows1257", RTL_TEXTENCODING_MS_1257 },
693cdf0e10cSrcweir         { "windows1258", RTL_TEXTENCODING_MS_1258 },
694cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
695cdf0e10cSrcweir     };
696cdf0e10cSrcweir 
697cdf0e10cSrcweir     /* All Identifiers are in lower case and contain only alphanumeric */
698cdf0e10cSrcweir     /* characters. The function search for the first matching string in */
699cdf0e10cSrcweir     /* the table. */
700cdf0e10cSrcweir     /* Sort order: unique (first iso885914, than iso88591), important */
701cdf0e10cSrcweir     static ImplStrCharsetDef const aMimeCharsetTab[] =
702cdf0e10cSrcweir     {
703cdf0e10cSrcweir         { "unicode11utf7", RTL_TEXTENCODING_UTF7 },
704cdf0e10cSrcweir         { "caunicode11utf7", RTL_TEXTENCODING_UTF7 },
705cdf0e10cSrcweir         { "iso88591windows30", RTL_TEXTENCODING_ISO_8859_1 },
706cdf0e10cSrcweir         { "iso88591win", RTL_TEXTENCODING_MS_1252 },
707cdf0e10cSrcweir         { "iso88592win", RTL_TEXTENCODING_MS_1250 },
708cdf0e10cSrcweir         { "iso88599win", RTL_TEXTENCODING_MS_1254 },
709cdf0e10cSrcweir         { "iso885915", RTL_TEXTENCODING_ISO_8859_15 },
710cdf0e10cSrcweir         { "iso885914", RTL_TEXTENCODING_ISO_8859_14 },
711cdf0e10cSrcweir         { "iso885913", RTL_TEXTENCODING_ISO_8859_13 },
712cdf0e10cSrcweir         { "iso885911", RTL_TEXTENCODING_TIS_620 },
713cdf0e10cSrcweir             /* This is no official MIME character set name, but it might be in
714cdf0e10cSrcweir                use in Thailand. */
715cdf0e10cSrcweir         { "iso885910", RTL_TEXTENCODING_ISO_8859_10 },
716cdf0e10cSrcweir         { "iso88591", RTL_TEXTENCODING_ISO_8859_1 },
717cdf0e10cSrcweir         { "iso88592", RTL_TEXTENCODING_ISO_8859_2 },
718cdf0e10cSrcweir         { "iso88593", RTL_TEXTENCODING_ISO_8859_3 },
719cdf0e10cSrcweir         { "iso88594", RTL_TEXTENCODING_ISO_8859_4 },
720cdf0e10cSrcweir         { "iso88595", RTL_TEXTENCODING_ISO_8859_5 },
721cdf0e10cSrcweir         { "iso88596", RTL_TEXTENCODING_ISO_8859_6 },
722cdf0e10cSrcweir         { "iso88597", RTL_TEXTENCODING_ISO_8859_7 },
723cdf0e10cSrcweir         { "iso88598", RTL_TEXTENCODING_ISO_8859_8 },
724cdf0e10cSrcweir         { "iso88599", RTL_TEXTENCODING_ISO_8859_9 },
725cdf0e10cSrcweir         { "isoir100", RTL_TEXTENCODING_ISO_8859_1 },
726cdf0e10cSrcweir         { "latin1", RTL_TEXTENCODING_ISO_8859_1 },
727cdf0e10cSrcweir         { "l1", RTL_TEXTENCODING_ISO_8859_1 },
728cdf0e10cSrcweir         { "cp819", RTL_TEXTENCODING_ISO_8859_1 },
729cdf0e10cSrcweir         { "ibm819", RTL_TEXTENCODING_ISO_8859_1 },
730cdf0e10cSrcweir         { "csisolatin1", RTL_TEXTENCODING_ISO_8859_1 },
731cdf0e10cSrcweir         { "isoir101", RTL_TEXTENCODING_ISO_8859_2 },
732cdf0e10cSrcweir         { "latin2", RTL_TEXTENCODING_ISO_8859_2 },
733cdf0e10cSrcweir         { "l2", RTL_TEXTENCODING_ISO_8859_2 },
734cdf0e10cSrcweir         { "csisolatin2", RTL_TEXTENCODING_ISO_8859_2 },
735cdf0e10cSrcweir         { "isoir109", RTL_TEXTENCODING_ISO_8859_3 },
736cdf0e10cSrcweir         { "latin3", RTL_TEXTENCODING_ISO_8859_3 },
737cdf0e10cSrcweir         { "l3", RTL_TEXTENCODING_ISO_8859_3 },
738cdf0e10cSrcweir         { "csisolatin3", RTL_TEXTENCODING_ISO_8859_3 },
739cdf0e10cSrcweir         { "isoir110", RTL_TEXTENCODING_ISO_8859_4 },
740cdf0e10cSrcweir         { "latin4", RTL_TEXTENCODING_ISO_8859_4 },
741cdf0e10cSrcweir         { "l4", RTL_TEXTENCODING_ISO_8859_4 },
742cdf0e10cSrcweir         { "csisolatin4", RTL_TEXTENCODING_ISO_8859_4 },
743cdf0e10cSrcweir         { "isoir144", RTL_TEXTENCODING_ISO_8859_5 },
744cdf0e10cSrcweir         { "cyrillicasian", RTL_TEXTENCODING_PT154 },
745cdf0e10cSrcweir         { "cyrillic", RTL_TEXTENCODING_ISO_8859_5 },
746cdf0e10cSrcweir         { "csisolatincyrillic", RTL_TEXTENCODING_ISO_8859_5 },
747cdf0e10cSrcweir         { "isoir127", RTL_TEXTENCODING_ISO_8859_6 },
748cdf0e10cSrcweir         { "arabic", RTL_TEXTENCODING_ISO_8859_6 },
749cdf0e10cSrcweir         { "csisolatinarabic", RTL_TEXTENCODING_ISO_8859_6 },
750cdf0e10cSrcweir         { "ecma114", RTL_TEXTENCODING_ISO_8859_6 },
751cdf0e10cSrcweir         { "asmo708", RTL_TEXTENCODING_ISO_8859_6 },
752cdf0e10cSrcweir         { "isoir126", RTL_TEXTENCODING_ISO_8859_7 },
753cdf0e10cSrcweir         { "greek", RTL_TEXTENCODING_ISO_8859_7 },
754cdf0e10cSrcweir         { "csisolatingreek", RTL_TEXTENCODING_ISO_8859_7 },
755cdf0e10cSrcweir         { "elot928", RTL_TEXTENCODING_ISO_8859_7 },
756cdf0e10cSrcweir         { "ecma118", RTL_TEXTENCODING_ISO_8859_7 },
757cdf0e10cSrcweir         { "isoir138", RTL_TEXTENCODING_ISO_8859_8 },
758cdf0e10cSrcweir         { "hebrew", RTL_TEXTENCODING_ISO_8859_8 },
759cdf0e10cSrcweir         { "csisolatinhebrew", RTL_TEXTENCODING_ISO_8859_8 },
760cdf0e10cSrcweir         { "isoir148", RTL_TEXTENCODING_ISO_8859_9 },
761cdf0e10cSrcweir         { "latin5", RTL_TEXTENCODING_ISO_8859_9 },
762cdf0e10cSrcweir         { "l5", RTL_TEXTENCODING_ISO_8859_9 },
763cdf0e10cSrcweir         { "csisolatin5", RTL_TEXTENCODING_ISO_8859_9 },
764cdf0e10cSrcweir         { "cswindows30latin1", RTL_TEXTENCODING_ISO_8859_1 },
765cdf0e10cSrcweir         { "cswindows30latin1", RTL_TEXTENCODING_ISO_8859_1 },
766cdf0e10cSrcweir         { "cswindows31latin1", RTL_TEXTENCODING_MS_1252 },
767cdf0e10cSrcweir         { "cswindows31latin2", RTL_TEXTENCODING_MS_1250 },
768cdf0e10cSrcweir         { "cswindows31latin5", RTL_TEXTENCODING_MS_1254 },
769cdf0e10cSrcweir         { "iso10646us", RTL_TEXTENCODING_ASCII_US },
770cdf0e10cSrcweir         { "iso646irv", RTL_TEXTENCODING_ASCII_US },
771cdf0e10cSrcweir         { "cskoi8r", RTL_TEXTENCODING_KOI8_R },
772cdf0e10cSrcweir         { "ibm437", RTL_TEXTENCODING_IBM_437 },
773cdf0e10cSrcweir         { "cp437", RTL_TEXTENCODING_IBM_437 },
774cdf0e10cSrcweir         { "437", RTL_TEXTENCODING_IBM_437 },
775cdf0e10cSrcweir         { "cspc8codepage437", RTL_TEXTENCODING_IBM_437 },
776cdf0e10cSrcweir         { "ansix34", RTL_TEXTENCODING_ASCII_US },
777cdf0e10cSrcweir         { "ibm367", RTL_TEXTENCODING_ASCII_US },
778cdf0e10cSrcweir         { "cp367", RTL_TEXTENCODING_ASCII_US },
779cdf0e10cSrcweir         { "csascii", RTL_TEXTENCODING_ASCII_US },
780cdf0e10cSrcweir         { "ibm775", RTL_TEXTENCODING_IBM_775 },
781cdf0e10cSrcweir         { "cp775", RTL_TEXTENCODING_IBM_775 },
782cdf0e10cSrcweir         { "cspc775baltic", RTL_TEXTENCODING_IBM_775 },
783cdf0e10cSrcweir         { "ibm850", RTL_TEXTENCODING_IBM_850 },
784cdf0e10cSrcweir         { "cp850", RTL_TEXTENCODING_IBM_850 },
785cdf0e10cSrcweir         { "850", RTL_TEXTENCODING_IBM_850 },
786cdf0e10cSrcweir         { "cspc850multilingual", RTL_TEXTENCODING_IBM_850 },
787cdf0e10cSrcweir /*        { "ibm851", RTL_TEXTENCODING_IBM_851 }, */
788cdf0e10cSrcweir /*        { "cp851", RTL_TEXTENCODING_IBM_851 }, */
789cdf0e10cSrcweir /*        { "851", RTL_TEXTENCODING_IBM_851 }, */
790cdf0e10cSrcweir /*        { "csibm851", RTL_TEXTENCODING_IBM_851 }, */
791cdf0e10cSrcweir         { "ibm852", RTL_TEXTENCODING_IBM_852 },
792cdf0e10cSrcweir         { "cp852", RTL_TEXTENCODING_IBM_852 },
793cdf0e10cSrcweir         { "852", RTL_TEXTENCODING_IBM_852 },
794cdf0e10cSrcweir         { "cspcp852", RTL_TEXTENCODING_IBM_852 },
795cdf0e10cSrcweir         { "ibm855", RTL_TEXTENCODING_IBM_855 },
796cdf0e10cSrcweir         { "cp855", RTL_TEXTENCODING_IBM_855 },
797cdf0e10cSrcweir         { "855", RTL_TEXTENCODING_IBM_855 },
798cdf0e10cSrcweir         { "csibm855", RTL_TEXTENCODING_IBM_855 },
799cdf0e10cSrcweir         { "ibm857", RTL_TEXTENCODING_IBM_857 },
800cdf0e10cSrcweir         { "cp857", RTL_TEXTENCODING_IBM_857 },
801cdf0e10cSrcweir         { "857", RTL_TEXTENCODING_IBM_857 },
802cdf0e10cSrcweir         { "csibm857", RTL_TEXTENCODING_IBM_857 },
803cdf0e10cSrcweir         { "ibm860", RTL_TEXTENCODING_IBM_860 },
804cdf0e10cSrcweir         { "cp860", RTL_TEXTENCODING_IBM_860 },
805cdf0e10cSrcweir         { "860", RTL_TEXTENCODING_IBM_860 },
806cdf0e10cSrcweir         { "csibm860", RTL_TEXTENCODING_IBM_860 },
807cdf0e10cSrcweir         { "ibm861", RTL_TEXTENCODING_IBM_861 },
808cdf0e10cSrcweir         { "cp861", RTL_TEXTENCODING_IBM_861 },
809cdf0e10cSrcweir         { "861", RTL_TEXTENCODING_IBM_861 },
810cdf0e10cSrcweir         { "csis", RTL_TEXTENCODING_IBM_861 },
811cdf0e10cSrcweir         { "csibm861", RTL_TEXTENCODING_IBM_861 },
812cdf0e10cSrcweir         { "ibm862", RTL_TEXTENCODING_IBM_862 },
813cdf0e10cSrcweir         { "cp862", RTL_TEXTENCODING_IBM_862 },
814cdf0e10cSrcweir         { "862", RTL_TEXTENCODING_IBM_862 },
815cdf0e10cSrcweir         { "cspc862latinhebrew", RTL_TEXTENCODING_IBM_862 },
816cdf0e10cSrcweir         { "ibm863", RTL_TEXTENCODING_IBM_863 },
817cdf0e10cSrcweir         { "cp863", RTL_TEXTENCODING_IBM_863 },
818cdf0e10cSrcweir         { "863", RTL_TEXTENCODING_IBM_863 },
819cdf0e10cSrcweir         { "csibm863", RTL_TEXTENCODING_IBM_863 },
820cdf0e10cSrcweir         { "ibm864", RTL_TEXTENCODING_IBM_864 },
821cdf0e10cSrcweir         { "cp864", RTL_TEXTENCODING_IBM_864 },
822cdf0e10cSrcweir         { "864", RTL_TEXTENCODING_IBM_864 },
823cdf0e10cSrcweir         { "csibm864", RTL_TEXTENCODING_IBM_864 },
824cdf0e10cSrcweir         { "ibm865", RTL_TEXTENCODING_IBM_865 },
825cdf0e10cSrcweir         { "cp865", RTL_TEXTENCODING_IBM_865 },
826cdf0e10cSrcweir         { "865", RTL_TEXTENCODING_IBM_865 },
827cdf0e10cSrcweir         { "csibm865", RTL_TEXTENCODING_IBM_865 },
828cdf0e10cSrcweir         { "ibm866", RTL_TEXTENCODING_IBM_866 },
829cdf0e10cSrcweir         { "cp866", RTL_TEXTENCODING_IBM_866 },
830cdf0e10cSrcweir         { "866", RTL_TEXTENCODING_IBM_866 },
831cdf0e10cSrcweir         { "csibm866", RTL_TEXTENCODING_IBM_866 },
832cdf0e10cSrcweir /*        { "ibm868", RTL_TEXTENCODING_IBM_868 }, */
833cdf0e10cSrcweir /*        { "cp868", RTL_TEXTENCODING_IBM_868 }, */
834cdf0e10cSrcweir /*        { "cpar", RTL_TEXTENCODING_IBM_868 }, */
835cdf0e10cSrcweir /*        { "csibm868", RTL_TEXTENCODING_IBM_868 }, */
836cdf0e10cSrcweir         { "ibm869", RTL_TEXTENCODING_IBM_869 },
837cdf0e10cSrcweir         { "cp869", RTL_TEXTENCODING_IBM_869 },
838cdf0e10cSrcweir         { "869", RTL_TEXTENCODING_IBM_869 },
839cdf0e10cSrcweir         { "cpgr", RTL_TEXTENCODING_IBM_869 },
840cdf0e10cSrcweir         { "csibm869", RTL_TEXTENCODING_IBM_869 },
841cdf0e10cSrcweir         { "ibm869", RTL_TEXTENCODING_IBM_869 },
842cdf0e10cSrcweir         { "cp869", RTL_TEXTENCODING_IBM_869 },
843cdf0e10cSrcweir         { "869", RTL_TEXTENCODING_IBM_869 },
844cdf0e10cSrcweir         { "cpgr", RTL_TEXTENCODING_IBM_869 },
845cdf0e10cSrcweir         { "csibm869", RTL_TEXTENCODING_IBM_869 },
846cdf0e10cSrcweir         { "mac", RTL_TEXTENCODING_APPLE_ROMAN },
847cdf0e10cSrcweir         { "csmacintosh", RTL_TEXTENCODING_APPLE_ROMAN },
848cdf0e10cSrcweir         { "shiftjis", RTL_TEXTENCODING_SHIFT_JIS },
849cdf0e10cSrcweir         { "mskanji", RTL_TEXTENCODING_MS_932 },
850cdf0e10cSrcweir         { "csshiftjis", RTL_TEXTENCODING_SHIFT_JIS },
851cdf0e10cSrcweir         { "jisx0208", RTL_TEXTENCODING_JIS_X_0208 },
852cdf0e10cSrcweir         { "jisc62261983", RTL_TEXTENCODING_JIS_X_0208 },
853cdf0e10cSrcweir         { "csiso87jisx0208", RTL_TEXTENCODING_JIS_X_0208 },
854cdf0e10cSrcweir         { "isoir86", RTL_TEXTENCODING_JIS_X_0208 },
855cdf0e10cSrcweir         { "x0208", RTL_TEXTENCODING_JIS_X_0208 },
856cdf0e10cSrcweir         { "jisx0201", RTL_TEXTENCODING_JIS_X_0201 },
857cdf0e10cSrcweir         { "cshalfwidthkatakana", RTL_TEXTENCODING_JIS_X_0201 },
858cdf0e10cSrcweir         { "x0201", RTL_TEXTENCODING_JIS_X_0201 },
859cdf0e10cSrcweir         { "jisx0212", RTL_TEXTENCODING_JIS_X_0212 },
860cdf0e10cSrcweir         { "csiso159jisx0212", RTL_TEXTENCODING_JIS_X_0212 },
861cdf0e10cSrcweir         { "isoir159", RTL_TEXTENCODING_JIS_X_0208 },
862cdf0e10cSrcweir         { "x0212", RTL_TEXTENCODING_JIS_X_0212 },
863cdf0e10cSrcweir         { "isoir6", RTL_TEXTENCODING_ASCII_US },
864cdf0e10cSrcweir         { "xsjis", RTL_TEXTENCODING_SHIFT_JIS },
865cdf0e10cSrcweir         { "sjis", RTL_TEXTENCODING_SHIFT_JIS },
866cdf0e10cSrcweir         { "ascii", RTL_TEXTENCODING_ASCII_US },
867cdf0e10cSrcweir         { "us", RTL_TEXTENCODING_ASCII_US },
868cdf0e10cSrcweir         { "gb180302000", RTL_TEXTENCODING_GB_18030 },
869cdf0e10cSrcweir             /* This is no actual MIME character set name, it is only in here
870cdf0e10cSrcweir                for backwards compatibility (before "GB18030" was officially
871cdf0e10cSrcweir                registered with IANA, this code contained some guesses of what
872cdf0e10cSrcweir                would become official names for GB18030). */
873cdf0e10cSrcweir         { "gb18030", RTL_TEXTENCODING_GB_18030 },
874cdf0e10cSrcweir         { "big5hkscs", RTL_TEXTENCODING_BIG5_HKSCS },
875cdf0e10cSrcweir         { "tis620", RTL_TEXTENCODING_TIS_620 },
876cdf0e10cSrcweir         { "gbk", RTL_TEXTENCODING_GBK },
877cdf0e10cSrcweir         { "cp936", RTL_TEXTENCODING_GBK },
878cdf0e10cSrcweir         { "ms936", RTL_TEXTENCODING_GBK },
879cdf0e10cSrcweir         { "windows936", RTL_TEXTENCODING_GBK },
880cdf0e10cSrcweir         { "cp874", RTL_TEXTENCODING_MS_874 },
881cdf0e10cSrcweir             /* This is no official MIME character set name, but it might be in
882cdf0e10cSrcweir                use in Thailand. */
883cdf0e10cSrcweir         { "ms874", RTL_TEXTENCODING_MS_874 },
884cdf0e10cSrcweir             /* This is no official MIME character set name, but it might be in
885cdf0e10cSrcweir                use in Thailand. */
886cdf0e10cSrcweir         { "windows874", RTL_TEXTENCODING_MS_874 },
887cdf0e10cSrcweir             /* This is no official MIME character set name, but it might be in
888cdf0e10cSrcweir                use in Thailand. */
889cdf0e10cSrcweir         { "koi8u", RTL_TEXTENCODING_KOI8_U },
890cdf0e10cSrcweir         { "cpis", RTL_TEXTENCODING_IBM_861 },
891cdf0e10cSrcweir         { "ksc56011987", RTL_TEXTENCODING_MS_949 },
892cdf0e10cSrcweir         { "isoir149", RTL_TEXTENCODING_MS_949 },
893cdf0e10cSrcweir         { "ksc56011989", RTL_TEXTENCODING_MS_949 },
894cdf0e10cSrcweir         { "ksc5601", RTL_TEXTENCODING_MS_949 },
895cdf0e10cSrcweir         { "korean", RTL_TEXTENCODING_MS_949 },
896cdf0e10cSrcweir         { "csksc56011987", RTL_TEXTENCODING_MS_949 },
897cdf0e10cSrcweir             /* Map KS_C_5601-1987 and aliases to MS-949 instead of EUC-KR, as
898cdf0e10cSrcweir                this character set identifier seems to be prominently used by MS
899cdf0e10cSrcweir                to stand for KS C 5601 plus MS-949 extensions */
900cdf0e10cSrcweir         { "latin9", RTL_TEXTENCODING_ISO_8859_15 },
901cdf0e10cSrcweir         { "adobestandardencoding", RTL_TEXTENCODING_ADOBE_STANDARD },
902cdf0e10cSrcweir         { "csadobestandardencoding", RTL_TEXTENCODING_ADOBE_STANDARD },
903cdf0e10cSrcweir         { "adobesymbolencoding", RTL_TEXTENCODING_ADOBE_SYMBOL },
904cdf0e10cSrcweir         { "cshppsmath", RTL_TEXTENCODING_ADOBE_SYMBOL },
905cdf0e10cSrcweir         { "ptcp154", RTL_TEXTENCODING_PT154 },
906cdf0e10cSrcweir         { "csptcp154", RTL_TEXTENCODING_PT154 },
907cdf0e10cSrcweir         { "pt154", RTL_TEXTENCODING_PT154 },
908cdf0e10cSrcweir         { "cp154", RTL_TEXTENCODING_PT154 },
909cdf0e10cSrcweir         { "xisciide", RTL_TEXTENCODING_ISCII_DEVANAGARI },
910cdf0e10cSrcweir             /* This is no official MIME character set name, but is in use by
911cdf0e10cSrcweir                various windows APIs. */
912cdf0e10cSrcweir         { NULL, RTL_TEXTENCODING_DONTKNOW }
913cdf0e10cSrcweir     };
914cdf0e10cSrcweir 
915cdf0e10cSrcweir     rtl_TextEncoding            eEncoding = RTL_TEXTENCODING_DONTKNOW;
916cdf0e10cSrcweir     sal_Char*                   pBuf;
917cdf0e10cSrcweir     const ImplStrCharsetDef*    pData = aVIPMimeCharsetTab;
918cdf0e10cSrcweir     sal_uInt32                  nBufLen = strlen( pMimeCharset )+1;
919cdf0e10cSrcweir 
920cdf0e10cSrcweir     /* Alloc Buffer and map to lower case and remove non alphanumeric chars */
921cdf0e10cSrcweir     pBuf = (char*)rtl_allocateMemory( nBufLen );
922cdf0e10cSrcweir     Impl_toAsciiLowerAndRemoveNonAlphanumeric( pMimeCharset, pBuf );
923cdf0e10cSrcweir 
924cdf0e10cSrcweir     /* Search for equal in the VIP table */
925cdf0e10cSrcweir     while ( pData->mpCharsetStr )
926cdf0e10cSrcweir     {
927cdf0e10cSrcweir         if ( strcmp( pBuf, pData->mpCharsetStr ) == 0 )
928cdf0e10cSrcweir         {
929cdf0e10cSrcweir             eEncoding = pData->meTextEncoding;
930cdf0e10cSrcweir             break;
931cdf0e10cSrcweir         }
932cdf0e10cSrcweir 
933cdf0e10cSrcweir         pData++;
934cdf0e10cSrcweir     }
935cdf0e10cSrcweir 
936cdf0e10cSrcweir     /* Search for matching in the mime table */
937cdf0e10cSrcweir     if ( eEncoding == RTL_TEXTENCODING_DONTKNOW )
938cdf0e10cSrcweir     {
939cdf0e10cSrcweir         pData = aMimeCharsetTab;
940cdf0e10cSrcweir         while ( pData->mpCharsetStr )
941cdf0e10cSrcweir         {
942cdf0e10cSrcweir             if ( Impl_matchString( pBuf, pData->mpCharsetStr ) )
943cdf0e10cSrcweir             {
944cdf0e10cSrcweir                 eEncoding = pData->meTextEncoding;
945cdf0e10cSrcweir                 break;
946cdf0e10cSrcweir             }
947cdf0e10cSrcweir 
948cdf0e10cSrcweir             pData++;
949cdf0e10cSrcweir         }
950cdf0e10cSrcweir     }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir     rtl_freeMemory( pBuf );
953cdf0e10cSrcweir 
954cdf0e10cSrcweir     return eEncoding;
955cdf0e10cSrcweir }
956cdf0e10cSrcweir 
957cdf0e10cSrcweir /* ======================================================================= */
958cdf0e10cSrcweir 
959cdf0e10cSrcweir sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding )
960cdf0e10cSrcweir {
961cdf0e10cSrcweir     const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
962cdf0e10cSrcweir     if ( pData )
963cdf0e10cSrcweir         return pData->mnBestWindowsCharset;
964cdf0e10cSrcweir     else
965cdf0e10cSrcweir         return 1;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir 
968cdf0e10cSrcweir /* ----------------------------------------------------------------------- */
969cdf0e10cSrcweir 
970cdf0e10cSrcweir const sal_Char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding  )
971cdf0e10cSrcweir {
972cdf0e10cSrcweir     const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
973cdf0e10cSrcweir     if ( pData )
974cdf0e10cSrcweir         return (sal_Char const *) pData->mpBestUnixCharset;
975cdf0e10cSrcweir     else if( eTextEncoding == RTL_TEXTENCODING_UNICODE )
976cdf0e10cSrcweir         return (sal_Char const *) "iso10646-1";
977cdf0e10cSrcweir     else
978cdf0e10cSrcweir         return 0;
979cdf0e10cSrcweir }
980cdf0e10cSrcweir 
981cdf0e10cSrcweir /* ----------------------------------------------------------------------- */
982cdf0e10cSrcweir 
983cdf0e10cSrcweir char const * SAL_CALL rtl_getMimeCharsetFromTextEncoding(rtl_TextEncoding
984cdf0e10cSrcweir                                                              nEncoding)
985cdf0e10cSrcweir {
986cdf0e10cSrcweir     ImplTextEncodingData const * p = Impl_getTextEncodingData(nEncoding);
987cdf0e10cSrcweir     return p && (p->mnInfoFlags & RTL_TEXTENCODING_INFO_MIME) != 0 ?
988cdf0e10cSrcweir                p->mpBestMimeCharset : NULL;
989cdf0e10cSrcweir }
990cdf0e10cSrcweir 
991cdf0e10cSrcweir const sal_Char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir     const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
994cdf0e10cSrcweir     if ( pData )
995cdf0e10cSrcweir         return (sal_Char const *) pData->mpBestMimeCharset;
996cdf0e10cSrcweir     else
997cdf0e10cSrcweir         return 0;
998cdf0e10cSrcweir }
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir /* The following two functions are based on <http://www.sharmahd.com/tm/
1001cdf0e10cSrcweir    codepages.html>, <http://msdn.microsoft.com/workshop/author/dhtml/reference/
1002cdf0e10cSrcweir    charsets/charset4.asp>, and <http://www.iana.org/assignments/character-sets>.
1003cdf0e10cSrcweir  */
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir rtl_TextEncoding SAL_CALL
1006cdf0e10cSrcweir rtl_getTextEncodingFromWindowsCodePage(sal_uInt32 nCodePage)
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir     switch (nCodePage)
1009cdf0e10cSrcweir     {
1010cdf0e10cSrcweir     case 437: return RTL_TEXTENCODING_IBM_437;
1011cdf0e10cSrcweir     case 708: return RTL_TEXTENCODING_ISO_8859_6;
1012cdf0e10cSrcweir     case 737: return RTL_TEXTENCODING_IBM_737;
1013cdf0e10cSrcweir     case 775: return RTL_TEXTENCODING_IBM_775;
1014cdf0e10cSrcweir     case 850: return RTL_TEXTENCODING_IBM_850;
1015cdf0e10cSrcweir     case 852: return RTL_TEXTENCODING_IBM_852;
1016cdf0e10cSrcweir     case 855: return RTL_TEXTENCODING_IBM_855;
1017cdf0e10cSrcweir     case 857: return RTL_TEXTENCODING_IBM_857;
1018cdf0e10cSrcweir     case 860: return RTL_TEXTENCODING_IBM_860;
1019cdf0e10cSrcweir     case 861: return RTL_TEXTENCODING_IBM_861;
1020cdf0e10cSrcweir     case 862: return RTL_TEXTENCODING_IBM_862;
1021cdf0e10cSrcweir     case 863: return RTL_TEXTENCODING_IBM_863;
1022cdf0e10cSrcweir     case 864: return RTL_TEXTENCODING_IBM_864;
1023cdf0e10cSrcweir     case 865: return RTL_TEXTENCODING_IBM_865;
1024cdf0e10cSrcweir     case 866: return RTL_TEXTENCODING_IBM_866;
1025cdf0e10cSrcweir     case 869: return RTL_TEXTENCODING_IBM_869;
1026cdf0e10cSrcweir     case 874: return RTL_TEXTENCODING_MS_874;
1027cdf0e10cSrcweir     case 932: return RTL_TEXTENCODING_MS_932;
1028cdf0e10cSrcweir     case 936: return RTL_TEXTENCODING_MS_936;
1029cdf0e10cSrcweir     case 949: return RTL_TEXTENCODING_MS_949;
1030cdf0e10cSrcweir     case 950: return RTL_TEXTENCODING_MS_950;
1031cdf0e10cSrcweir     case 1250: return RTL_TEXTENCODING_MS_1250;
1032cdf0e10cSrcweir     case 1251: return RTL_TEXTENCODING_MS_1251;
1033cdf0e10cSrcweir     case 1252: return RTL_TEXTENCODING_MS_1252;
1034cdf0e10cSrcweir     case 1253: return RTL_TEXTENCODING_MS_1253;
1035cdf0e10cSrcweir     case 1254: return RTL_TEXTENCODING_MS_1254;
1036cdf0e10cSrcweir     case 1255: return RTL_TEXTENCODING_MS_1255;
1037cdf0e10cSrcweir     case 1256: return RTL_TEXTENCODING_MS_1256;
1038cdf0e10cSrcweir     case 1257: return RTL_TEXTENCODING_MS_1257;
1039cdf0e10cSrcweir     case 1258: return RTL_TEXTENCODING_MS_1258;
1040cdf0e10cSrcweir     case 1361: return RTL_TEXTENCODING_MS_1361;
1041cdf0e10cSrcweir     case 10000: return RTL_TEXTENCODING_APPLE_ROMAN;
1042cdf0e10cSrcweir     case 10001: return RTL_TEXTENCODING_APPLE_JAPANESE;
1043cdf0e10cSrcweir     case 10002: return RTL_TEXTENCODING_APPLE_CHINTRAD;
1044cdf0e10cSrcweir     case 10003: return RTL_TEXTENCODING_APPLE_KOREAN;
1045cdf0e10cSrcweir     case 10004: return RTL_TEXTENCODING_APPLE_ARABIC;
1046cdf0e10cSrcweir     case 10005: return RTL_TEXTENCODING_APPLE_HEBREW;
1047cdf0e10cSrcweir     case 10006: return RTL_TEXTENCODING_APPLE_GREEK;
1048cdf0e10cSrcweir     case 10007: return RTL_TEXTENCODING_APPLE_CYRILLIC;
1049cdf0e10cSrcweir     case 10008: return RTL_TEXTENCODING_APPLE_CHINSIMP;
1050cdf0e10cSrcweir     case 10010: return RTL_TEXTENCODING_APPLE_ROMANIAN;
1051cdf0e10cSrcweir     case 10017: return RTL_TEXTENCODING_APPLE_UKRAINIAN;
1052cdf0e10cSrcweir     case 10029: return RTL_TEXTENCODING_APPLE_CENTEURO;
1053cdf0e10cSrcweir     case 10079: return RTL_TEXTENCODING_APPLE_ICELAND;
1054cdf0e10cSrcweir     case 10081: return RTL_TEXTENCODING_APPLE_TURKISH;
1055cdf0e10cSrcweir     case 10082: return RTL_TEXTENCODING_APPLE_CROATIAN;
1056cdf0e10cSrcweir     case 20127: return RTL_TEXTENCODING_ASCII_US;
1057cdf0e10cSrcweir     case 20866: return RTL_TEXTENCODING_KOI8_R;
1058cdf0e10cSrcweir     case 21866: return RTL_TEXTENCODING_KOI8_U;
1059cdf0e10cSrcweir     case 28591: return RTL_TEXTENCODING_ISO_8859_1;
1060cdf0e10cSrcweir     case 28592: return RTL_TEXTENCODING_ISO_8859_2;
1061cdf0e10cSrcweir     case 28593: return RTL_TEXTENCODING_ISO_8859_3;
1062cdf0e10cSrcweir     case 28594: return RTL_TEXTENCODING_ISO_8859_4;
1063cdf0e10cSrcweir     case 28595: return RTL_TEXTENCODING_ISO_8859_5;
1064cdf0e10cSrcweir     case 28596: return RTL_TEXTENCODING_ISO_8859_6;
1065cdf0e10cSrcweir     case 28597: return RTL_TEXTENCODING_ISO_8859_7;
1066cdf0e10cSrcweir     case 28598: return RTL_TEXTENCODING_ISO_8859_8;
1067cdf0e10cSrcweir     case 28599: return RTL_TEXTENCODING_ISO_8859_9;
1068cdf0e10cSrcweir     case 28605: return RTL_TEXTENCODING_ISO_8859_15;
1069cdf0e10cSrcweir     case 50220: return RTL_TEXTENCODING_ISO_2022_JP;
1070cdf0e10cSrcweir     case 50225: return RTL_TEXTENCODING_ISO_2022_KR;
1071cdf0e10cSrcweir     case 51932: return RTL_TEXTENCODING_EUC_JP;
1072cdf0e10cSrcweir     case 51936: return RTL_TEXTENCODING_EUC_CN;
1073cdf0e10cSrcweir     case 51949: return RTL_TEXTENCODING_EUC_KR;
1074cdf0e10cSrcweir     case 57002: return RTL_TEXTENCODING_ISCII_DEVANAGARI;
1075cdf0e10cSrcweir     case 65000: return RTL_TEXTENCODING_UTF7;
1076cdf0e10cSrcweir     case 65001: return RTL_TEXTENCODING_UTF8;
1077cdf0e10cSrcweir     default: return RTL_TEXTENCODING_DONTKNOW;
1078cdf0e10cSrcweir     }
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir sal_uInt32 SAL_CALL
1082cdf0e10cSrcweir rtl_getWindowsCodePageFromTextEncoding(rtl_TextEncoding nEncoding)
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir     switch (nEncoding)
1085cdf0e10cSrcweir     {
1086cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_437: return 437;
1087cdf0e10cSrcweir  /* case RTL_TEXTENCODING_ISO_8859_6: return 708; */
1088cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_737: return 737;
1089cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_775: return 775;
1090cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_850: return 850;
1091cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_852: return 852;
1092cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_855: return 855;
1093cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_857: return 857;
1094cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_860: return 860;
1095cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_861: return 861;
1096cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_862: return 862;
1097cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_863: return 863;
1098cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_864: return 864;
1099cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_865: return 865;
1100cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_866: return 866;
1101cdf0e10cSrcweir     case RTL_TEXTENCODING_IBM_869: return 869;
1102cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_874: return 874;
1103cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_932: return 932;
1104cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_936: return 936;
1105cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_949: return 949;
1106cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_950: return 950;
1107cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1250: return 1250;
1108cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1251: return 1251;
1109cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1252: return 1252;
1110cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1253: return 1253;
1111cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1254: return 1254;
1112cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1255: return 1255;
1113cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1256: return 1256;
1114cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1257: return 1257;
1115cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1258: return 1258;
1116cdf0e10cSrcweir     case RTL_TEXTENCODING_MS_1361: return 1361;
1117cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_ROMAN: return 10000;
1118cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_JAPANESE: return 10001;
1119cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_CHINTRAD: return 10002;
1120cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_KOREAN: return 10003;
1121cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_ARABIC: return 10004;
1122cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_HEBREW: return 10005;
1123cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_GREEK: return 10006;
1124cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_CYRILLIC: return 10007;
1125cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_CHINSIMP: return 10008;
1126cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_ROMANIAN: return 10010;
1127cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_UKRAINIAN: return 10017;
1128cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_CENTEURO: return 10029;
1129cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_ICELAND: return 10079;
1130cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_TURKISH: return 10081;
1131cdf0e10cSrcweir     case RTL_TEXTENCODING_APPLE_CROATIAN: return 10082;
1132cdf0e10cSrcweir     case RTL_TEXTENCODING_ASCII_US: return 20127;
1133cdf0e10cSrcweir     case RTL_TEXTENCODING_KOI8_R: return 20866;
1134cdf0e10cSrcweir     case RTL_TEXTENCODING_KOI8_U: return 21866;
1135cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_1: return 28591;
1136cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_2: return 28592;
1137cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_3: return 28593;
1138cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_4: return 28594;
1139cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_5: return 28595;
1140cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_6: return 28596;
1141cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_7: return 28597;
1142cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_8: return 28598;
1143cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_9: return 28599;
1144cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_8859_15: return 28605;
1145cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_2022_JP: return 50220;
1146cdf0e10cSrcweir     case RTL_TEXTENCODING_ISO_2022_KR: return 50225;
1147cdf0e10cSrcweir     case RTL_TEXTENCODING_EUC_JP: return 51932;
1148cdf0e10cSrcweir     case RTL_TEXTENCODING_EUC_CN: return 51936;
1149cdf0e10cSrcweir     case RTL_TEXTENCODING_EUC_KR: return 51949;
1150cdf0e10cSrcweir     case RTL_TEXTENCODING_ISCII_DEVANAGARI: return 57002;
1151cdf0e10cSrcweir     case RTL_TEXTENCODING_UTF7: return 65000;
1152cdf0e10cSrcweir     case RTL_TEXTENCODING_UTF8: return 65001;
1153cdf0e10cSrcweir     default: return 0;
1154cdf0e10cSrcweir     }
1155cdf0e10cSrcweir }
1156