1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sal.hxx" 26 27 /* TODO! This file should not be called textenc.c, because it is not the 28 implementation of rtl/textenc.h. Rather, it should be called 29 gettextencodingdata.c. */ 30 #include "gettextencodingdata.h" 31 #include "tenchelp.h" 32 #include "rtl/textenc.h" 33 34 #ifndef INCLUDED_STDDEF_H 35 #include <stddef.h> 36 #define INCLUDED_STDDEF_H 37 #endif 38 39 #define NOTABUNI_START 0xFF 40 #define NOTABUNI_END 0x00 41 42 #define NOTABCHAR_START 0xFFFF 43 #define NOTABCHAR_END 0x0000 44 45 #define SAME8090UNI_START 0x80 46 #define SAME8090UNI_END 0x9F 47 static sal_uInt16 const aImpl8090SameToUniTab[SAME8090UNI_END 48 - SAME8090UNI_START 49 + 1] 50 = { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, /* 0x80 */ 51 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 52 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, /* 0x90 */ 53 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F }; 54 55 #define SAME8090CHAR_START 0x0080 56 #define SAME8090CHAR_END 0x009F 57 static sal_uChar const aImpl8090SameToCharTab[SAME8090CHAR_END 58 - SAME8090CHAR_START 59 + 1] 60 = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x0080 */ 61 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 62 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x0090 */ 63 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F }; 64 65 #define SAMEA0FFCHAR_START 0x00A0 66 #define SAMEA0FFCHAR_END 0x00FF 67 static sal_uChar const aImplA0FFSameToCharTab[SAMEA0FFCHAR_END 68 - SAMEA0FFCHAR_START 69 + 1] 70 = { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, /* 0x00A0 */ 71 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 72 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, /* 0x00B0 */ 73 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 74 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 0x00C0 */ 75 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 76 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, /* 0x00D0 */ 77 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 78 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, /* 0x00E0 */ 79 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 80 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 0x00F0 */ 81 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; 82 83 static sal_uInt16 const aImplDoubleByteIdentifierTab[1] = { 0 }; 84 85 #include "tcvtarb1.tab" 86 #include "tcvteas1.tab" 87 #include "tcvtest1.tab" 88 #include "tcvtjp1.tab" 89 #include "tcvtjp2.tab" 90 #include "tcvtjp3.tab" 91 #include "tcvtjp4.tab" 92 #include "tcvtjp5.tab" 93 #include "tcvtjp6.tab" 94 #include "tcvtkr1.tab" 95 #include "tcvtkr2.tab" 96 #include "tcvtkr4.tab" 97 #include "tcvtkr5.tab" 98 #include "tcvtkr6.tab" 99 #include "tcvtlat1.tab" 100 #include "tcvtscn1.tab" 101 #include "tcvtscn2.tab" 102 #include "tcvtscn3.tab" 103 #include "tcvtscn4.tab" 104 #include "tcvtscn5.tab" 105 #include "tcvtscn6.tab" 106 #include "tcvtsym1.tab" 107 #include "tcvttcn1.tab" 108 #include "tcvttcn2.tab" 109 #include "tcvttcn6.tab" 110 #include "tcvtuni1.tab" 111 #include "convertiscii.tab" 112 113 #include "convertbig5hkscs.tab" 114 #include "converteuctw.tab" 115 #include "convertgb18030.tab" 116 #include "convertiso2022cn.tab" 117 #include "convertiso2022jp.tab" 118 #include "convertiso2022kr.tab" 119 #include "convertadobe.tab" 120 121 ImplTextEncodingData const * 122 Impl_getTextEncodingData(rtl_TextEncoding nEncoding) SAL_THROW_EXTERN_C() 123 { 124 static ImplTextEncodingData const * const aData[] 125 = { NULL, /* DONTKNOW */ 126 &aImplMS1252TextEncodingData, /* MS_1252 */ 127 &aImplAPPLEROMANTextEncodingData, /* APPLE_ROMAN */ 128 &aImplIBM437TextEncodingData, /* IBM_437 */ 129 &aImplIBM850TextEncodingData, /* IBM_850 */ 130 &aImplIBM860TextEncodingData, /* IBM_860 */ 131 &aImplIBM861TextEncodingData, /* IBM_861 */ 132 &aImplIBM863TextEncodingData, /* IBM_863 */ 133 &aImplIBM865TextEncodingData, /* IBM_865 */ 134 NULL, /* reserved (SYSTEM) */ 135 &aImplSYMBOLTextEncodingData, /* SYMBOL */ 136 &aImplUSASCIITextEncodingData, /* ASCII_US */ 137 &aImplISO88591TextEncodingData, /* ISO_8859_1 */ 138 &aImplISO88592TextEncodingData, /* ISO_8859_2 */ 139 &aImplISO88593TextEncodingData, /* ISO_8859_3 */ 140 &aImplISO88594TextEncodingData, /* ISO_8859_4 */ 141 &aImplISO88595TextEncodingData, /* ISO_8859_5 */ 142 &aImplISO88596TextEncodingData, /* ISO_8859_6 */ 143 &aImplISO88597TextEncodingData, /* ISO_8859_7 */ 144 &aImplISO88598TextEncodingData, /* ISO_8859_8 */ 145 &aImplISO88599TextEncodingData, /* ISO_8859_9 */ 146 &aImplISO885914TextEncodingData, /* ISO_8859_14 */ 147 &aImplISO885915TextEncodingData, /* ISO_8859_15 */ 148 &aImplIBM737TextEncodingData, /* IBM_737 */ 149 &aImplIBM775TextEncodingData, /* IBM_775 */ 150 &aImplIBM852TextEncodingData, /* IBM_852 */ 151 &aImplIBM855TextEncodingData, /* IBM_855 */ 152 &aImplIBM857TextEncodingData, /* IBM_857 */ 153 &aImplIBM862TextEncodingData, /* IBM_862 */ 154 &aImplIBM864TextEncodingData, /* IBM_864 */ 155 &aImplIBM866TextEncodingData, /* IBM_866 */ 156 &aImplIBM869TextEncodingData, /* IBM_869 */ 157 &aImplMS874TextEncodingData, /* MS_874 */ 158 &aImplMS1250TextEncodingData, /* MS_1250 */ 159 &aImplMS1251TextEncodingData, /* MS_1251 */ 160 &aImplMS1253TextEncodingData, /* MS_1253 */ 161 &aImplMS1254TextEncodingData, /* MS_1254 */ 162 &aImplMS1255TextEncodingData, /* MS_1255 */ 163 &aImplMS1256TextEncodingData, /* MS_1256 */ 164 &aImplMS1257TextEncodingData, /* MS_1257 */ 165 &aImplMS1258TextEncodingData, /* MS_1258 */ 166 NULL, /* TODO! APPLE_ARABIC */ 167 &aImplAPPLECENTEUROTextEncodingData, /* APPLE_CENTEURO */ 168 &aImplAPPLECROATIANTextEncodingData, /* APPLE_CROATIAN */ 169 &aImplAPPLECYRILLICTextEncodingData, /* APPLE_CYRILLIC */ 170 NULL, /* TODO! APPLE_DEVANAGARI */ 171 NULL, /* TODO! APPLE_FARSI */ 172 &aImplAPPLEGREEKTextEncodingData, /* APPLE_GREEK */ 173 NULL, /* TODO! APPLE_GUJARATI */ 174 NULL, /* TODO! APPLE_GURMUKHI */ 175 NULL, /* TODO! APPLE_HEBREW */ 176 &aImplAPPLEICELANDTextEncodingData, /* APPLE_ICELAND */ 177 &aImplAPPLEROMANIANTextEncodingData, /* APPLE_ROMANIAN */ 178 NULL, /* TODO! APPLE_THAI */ 179 &aImplAPPLETURKISHTextEncodingData, /* APPLE_TURKISH */ 180 &aImplAPPLEUKRAINIANTextEncodingData, /* APPLE_UKRAINIAN */ 181 &aImplAPPLECHINSIMPTextEncodingData, /* APPLE_CHINSIMP */ 182 &aImplAPPLECHINTRADTextEncodingData, /* APPLE_CHINTRAD */ 183 &aImplAPPLEJAPANESETextEncodingData, /* APPLE_JAPANESE */ 184 &aImplAPPLEKOREANTextEncodingData, /* APPLE_KOREAN */ 185 &aImplMS932TextEncodingData, /* MS_932 */ 186 &aImplMS936TextEncodingData, /* MS_936 */ 187 &aImplMS949TextEncodingData, /* MS_949 */ 188 &aImplMS950TextEncodingData, /* MS_950 */ 189 &aImplSJISTextEncodingData, /* SHIFT_JIS */ 190 &aImplGB2312TextEncodingData, /* GB_2312 */ 191 &aImplGBT12345TextEncodingData, /* GBT_12345 */ 192 &aImplGBKTextEncodingData, /* GBK */ 193 &aImplBIG5TextEncodingData, /* BIG5 */ 194 &aImplEUCJPTextEncodingData, /* EUC_JP */ 195 &aImplEUCCNTextEncodingData, /* EUC_CN */ 196 &aImplEucTwTextEncodingData, /* EUC_TW */ 197 &aImplIso2022JpTextEncodingData, /* ISO_2022_JP */ 198 &aImplIso2022CnTextEncodingData, /* ISO_2022_CN */ 199 &aImplKOI8RTextEncodingData, /* KOI8_R */ 200 &aImplUTF7TextEncodingData, /* UTF7 */ 201 &aImplUTF8TextEncodingData, /* UTF8 */ 202 &aImplISO885910TextEncodingData, /* ISO_8859_10 */ 203 &aImplISO885913TextEncodingData, /* ISO_8859_13 */ 204 &aImplEUCKRTextEncodingData, /* EUC_KR */ 205 &aImplIso2022KrTextEncodingData, /* ISO_2022_KR */ 206 &aImplJISX0201TextEncodingData, /* JIS_X_0201 */ 207 &aImplJISX0208TextEncodingData, /* JIS_X_0208 */ 208 &aImplJISX0212TextEncodingData, /* JIS_X_0212 */ 209 &aImplMS1361TextEncodingData, /* MS_1361 */ 210 &aImplGb18030TextEncodingData, /* GB_18030 */ 211 &aImplBig5HkscsTextEncodingData, /* BIG5_HKSCS */ 212 &aImplTis620TextEncodingData, /* TIS_620 */ 213 &aImplKoi8UTextEncodingData, /* KOI8_U */ 214 &aImplIsciiDevanagariTextEncodingData, /* ISCII_DEVANAGARI */ 215 &aImplJavaUtf8TextEncodingData, /* JAVA_UTF8 */ 216 &adobeStandardEncodingData, /* ADOBE_STANDARD */ 217 &adobeSymbolEncodingData, /* ADOBE_SYMBOL */ 218 &aImplPT154TextEncodingData, /* PT154 */ 219 &adobeDingbatsEncodingData }; /* ADOBE_DINGBATS */ 220 return 221 nEncoding < sizeof aData / sizeof aData[0] ? aData[nEncoding] : NULL; 222 } 223