Back to index

lightning-sunbird  0.9+nobinonly
nsCSIDtoCharsetName.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK *****
00038  *
00039  * This Original Code has been modified by IBM Corporation.
00040  * Modifications made by IBM described herein are
00041  * Copyright (c) International Business Machines
00042  * Corporation, 1999
00043  *
00044  * Modifications to Mozilla code or documentation
00045  * identified per MPL Section 3.3
00046  *
00047  * Date         Modified by     Description of modification
00048  * 12/09/1999   IBM Corp.       Support for IBM codepages - 850,852,855,857,862,864
00049  *
00050  */
00051 
00052 #include "nsI18nCompatibility.h"
00053 
00055 
00056 /* Codeset type */
00057 #define SINGLEBYTE   0x0000 /* 0000 0000 0000 0000 =    0 */
00058 #define MULTIBYTE    0x0100 /* 0000 0001 0000 0000 =  256 */
00059 #define STATEFUL     0x0200 /* 0000 0010 0000 0000 =  512 */
00060 #define WIDECHAR     0x0300 /* 0000 0011 0000 0000 =  768 */
00061 #define CODESET_MASK 0x0F00 /* 0000 1111 0000 0000 = 3840 */
00062 
00063 /*
00064  * Check for double byte encodings
00065  * (should distinguish 2 byte from true multibyte)
00066  */
00067 #define IS_16BIT_ENCODING(x) (((x)&CODESET_MASK) == MULTIBYTE)
00068 
00069 /* line-break on spaces */
00070 #define CS_SPACE   0x0400 /* 0000 0100 0000 0000 = 1024 */
00071 
00072 /* Auto Detect Mode */
00073 #define CS_AUTO    0x0800 /* 0000 1000 0000 0000 = 2048 */
00074 
00075 
00076 /* Code Set IDs */
00077 /* CS_DEFAULT: used if no charset param in header */
00078 /* CS_UNKNOWN: used for unrecognized charset */
00079 
00080                     /* type                  id   */
00081 #define CS_DEFAULT    (SINGLEBYTE         |   0) /*    0 */
00082 #define CS_ASCII      (SINGLEBYTE         |   1) /*    1 */
00083 #define CS_LATIN1     (SINGLEBYTE         |   2) /*    2 */
00084 #define CS_JIS        (STATEFUL           |   3) /*  515 */
00085 #define CS_SJIS       (MULTIBYTE          |   4) /*  260 */
00086 #define CS_EUCJP      (MULTIBYTE          |   5) /*  261 */
00087 
00088 #define CS_JIS_AUTO   (CS_AUTO|STATEFUL   |   3) /* 2563 */
00089 #define CS_SJIS_AUTO  (CS_AUTO|MULTIBYTE  |   4) /* 2308 */
00090 #define CS_EUCJP_AUTO (CS_AUTO|MULTIBYTE  |   5) /* 2309 */
00091 
00092 #define CS_MAC_ROMAN  (SINGLEBYTE         |   6) /*    6 */
00093 #define CS_BIG5       (MULTIBYTE          |   7) /*  263 */
00094 #define CS_GB_8BIT    (MULTIBYTE          |   8) /*  264 */
00095 #define CS_CNS_8BIT   (MULTIBYTE          |   9) /*  265 */
00096 #define CS_LATIN2     (SINGLEBYTE         |  10) /*   10 */
00097 #define CS_MAC_CE     (SINGLEBYTE         |  11) /*   11 */
00098 #define CS_KSC_8BIT   (MULTIBYTE|CS_SPACE |  12) /* 1292 */
00099 
00100 /* Jack Liu adds the following two entries */
00101 #define CS_KSC_8BIT_AUTO   (CS_AUTO | MULTIBYTE|CS_SPACE |  12)
00102 
00103 #define CS_2022_KR    (STATEFUL           |  13) /*  525 */
00104 #define CS_8859_3     (SINGLEBYTE         |  14) /*   14 */
00105 #define CS_8859_4     (SINGLEBYTE         |  15) /*   15 */
00106 #define CS_8859_5     (SINGLEBYTE         |  16) /*   16 ISO Cyrillic */
00107 #define CS_8859_6     (SINGLEBYTE         |  17) /*   17 ISO Arabic */
00108 #define CS_8859_7     (SINGLEBYTE         |  18) /*   18 ISO Greek */
00109 #define CS_8859_8     (SINGLEBYTE         |  19) /*   19 ISO Hebrew */
00110 #define CS_8859_9     (SINGLEBYTE         |  20) /*   20 */
00111 #define CS_SYMBOL     (SINGLEBYTE         |  21) /*   21 */
00112 #define CS_DINGBATS   (SINGLEBYTE         |  22) /*   22 */
00113 #define CS_DECTECH    (SINGLEBYTE         |  23) /*   23 */
00114 #define CS_CNS11643_1 (MULTIBYTE          |  24) /*  280 */
00115 #define CS_CNS11643_2 (MULTIBYTE          |  25) /*  281 */
00116 #define CS_JISX0208   (MULTIBYTE          |  26) /*  282 */
00117 #define CS_JISX0201   (SINGLEBYTE         |  27) /*   27 */
00118 #define CS_KSC5601    (MULTIBYTE          |  28) /*  284 */
00119 #define CS_TIS620     (SINGLEBYTE         |  29) /*   29 */
00120 #define CS_JISX0212   (MULTIBYTE          |  30) /*  286 */
00121 #define CS_GB2312     (MULTIBYTE          |  31) /*  287 */
00122 #define CS_UCS2       (WIDECHAR           |  32) /*  810 */
00123 #define CS_UCS4       (WIDECHAR           |  33) /*  811 */
00124 #define CS_UTF8       (MULTIBYTE          |  34) /*  290 */
00125 #define CS_UTF7       (STATEFUL           |  35) /*   35 */
00126 #define CS_NPC        (MULTIBYTE          |  36) /*  292 */
00127 #define CS_X_BIG5     (MULTIBYTE          |  37) /*  293 */
00128 #define CS_USRDEF2    (SINGLEBYTE         |  38) /*   38 */
00129 
00130 #define CS_KOI8_R     (SINGLEBYTE         |  39) /*   39 */
00131 #define CS_MAC_CYRILLIC     (SINGLEBYTE   |  40) /*   40 */
00132 #define CS_CP_1251    (SINGLEBYTE         |  41) /*   41 CS_CP_1251 is window Cyrillic */
00133 #define CS_MAC_GREEK  (SINGLEBYTE         |  42) /*   42 */
00134 /* CS_CP_1253 should be delete we should use CS_8859_7 instead */
00135 #define CS_CP_1253    (SINGLEBYTE         |  43) /*   43 CS_CP_1253 is window Greek */
00136 #define CS_CP_1250    (SINGLEBYTE         |  44) /*   44 CS_CP_1250 is window Centrl Europe */
00137 /* CS_CP_1254 should be delete we should use CS_8859_9 instead */
00138 #define CS_CP_1254    (SINGLEBYTE         |  45) /*   45 CS_CP_1254 is window Turkish */
00139 #define CS_MAC_TURKISH (SINGLEBYTE        |  46) /*   46 */
00140 #define CS_GB2312_11  (MULTIBYTE          |  47) /*  303 */
00141 #define CS_JISX0208_11 (MULTIBYTE         |  48) /*  304 */
00142 #define CS_KSC5601_11 (MULTIBYTE          |  49) /*  305 */
00143 #define CS_CNS11643_1110 (MULTIBYTE       |  50) /*  306 */
00144 #define CS_UCS2_SWAP    (WIDECHAR         |  51) /*  819 */
00145 #define CS_IMAP4_UTF7       (STATEFUL     |  52) /*  564 */
00146 #define CS_T61              (MULTIBYTE      |  53) /* This line should not merged into 5.0  */
00147 #define CS_HZ         (STATEFUL           |  54) /*   566 */
00148 
00149 #define CS_CP_850     (SINGLEBYTE         |  55) /*   55  PC Latin 1 */
00150 #define CS_CP_852     (SINGLEBYTE         |  56) /*   56  PC Latin 2 */
00151 #define CS_CP_855     (SINGLEBYTE         |  57) /*   57  PC Cyrillic */
00152 #define CS_CP_857     (SINGLEBYTE         |  58) /*   58  PC Turkish */
00153 #define CS_CP_862     (SINGLEBYTE         |  59) /*   59  PC Hebrew */
00154 #define CS_CP_864     (SINGLEBYTE         |  60) /*   60  PC Arabic */
00155 #define CS_CP_866     (SINGLEBYTE         |  61) /*   61  PC Russian */
00156 #define CS_CP_1255    (SINGLEBYTE         |  62) /*   62  Windows Hebrew */
00157 #define CS_CP_1256    (SINGLEBYTE         |  63) /*   63  Windows Arabic */
00158 #define CS_CP_1257    (SINGLEBYTE         |  64) /*   64  Windows Baltic */
00159 #define CS_CP_1258    (SINGLEBYTE         |  65) /*   65  Windows Vietnamese */
00160 #define CS_8859_15    (SINGLEBYTE         |  66) /*   66  EURO Support latin */
00161 #define INTL_CHAR_SET_MAX                    67  /* must be highest + 1 */
00162 
00163 #define CS_USER_DEFINED_ENCODING (SINGLEBYTE | 254) /* 254 */
00164 #define CS_UNKNOWN    (SINGLEBYTE         | 255) /* 255 */
00165 
00166 #define IS_UTF8_CSID(x) (((x)&0xFF)== (CS_UTF8&0xFF))
00167 #define IS_UNICODE_CSID(x) \
00168                      (   (((x)&0xFF)== (CS_UCS2&0xFF)) \
00169                       || (((x)&0xFF)== (CS_UTF8&0xFF)) \
00170                       || (((x)&0xFF)== (CS_UTF7&0xFF)) )
00171 
00172 /* Jack Liu (jliu) add the following. The trigger is passing the parameter to 
00173    PA_FetchParamValue() to satisfy its signature */
00174 #if defined(XP_MAC) || defined(XP_MACOSX)
00175 #define CS_FE_ASCII CS_MAC_ROMAN
00176 #else
00177 #define CS_FE_ASCII CS_LATIN1
00178 #endif
00179 
00181 
00182 #ifndef MAX_CSNAME
00183 #define MAX_CSNAME   64
00184 #endif
00185 
00186 typedef struct _csname2id_t {
00187        char   cs_name[MAX_CSNAME];
00188        char   java_name[MAX_CSNAME];
00189        PRUint16             cs_id;
00190        char   fill[3];
00191 } csname2id_t;
00192 
00193 
00194 /* Charset names and aliases from RFC 1700. Also encloded equivelend Java encoding names. Names are case
00195  * insenstive. Currently searches table linearly, so keep commonly used names at the beginning.
00196  */
00197 static csname2id_t csname2id_tbl[] = {
00198                                                                              /* default if not specified */
00199                      {"x-default", "", CS_DEFAULT},                   /* or unknown charset              */
00200 
00201                      {"us-ascii", "8859_1", CS_ASCII},
00202                      {"iso-8859-1", "8859_1", CS_LATIN1},
00203                      {"iso-2022-jp", "JIS", CS_JIS},
00204                      {"iso-2022-jp-2", "JIS", CS_JIS},         /* treat same as iso-2022-jp*/
00205                      {"Shift_JIS", "SJIS", CS_SJIS},
00206                      {"euc-jp", "EUCJIS", CS_EUCJP},
00207                      {"jis_x0208-1983", "JIS0208", CS_JISX0208},
00208                      {"x-jisx0208-11", "JIS0208", CS_JISX0208_11},
00209                      {"jis_x0201", "JIS0208", CS_JISX0201},
00210                      {"jis_x0212-1990", "JIS0208", CS_JISX0212},
00211                      {"x-mac-roman", "MacRoman", CS_MAC_ROMAN}, 
00212                      {"iso-8859-2", "8859_2", CS_LATIN2},
00213                      {"iso-8859-3", "8859_3", CS_8859_3},
00214                      {"iso-8859-4", "8859_4", CS_8859_4},
00215                      {"iso-8859-5", "8859_5", CS_8859_5},
00216                      {"iso-8859-6", "8859_6", CS_8859_6},
00217                      {"iso-8859-7", "8859_7", CS_8859_7},
00218                      {"iso-8859-8", "8859_8", CS_8859_8},
00219                      {"iso-8859-9", "8859_9", CS_8859_9},
00220                      {"iso-8859-15", "8859_15", CS_8859_15},
00221                      {"iso8859-15", "8859_15", CS_8859_15},
00222                      {"x-mac-ce", "MacCentralEurope", CS_MAC_CE},
00223                      {"EUC-KR", "KSC5601", CS_KSC_8BIT},       /* change to UPPER case per Jungshik Shin <jshin@pantheon.yale.edu> request to work around Korean SendMail Decode bug */
00224                      {"ks_c_5601-1987", "KSC5601", CS_KSC5601},
00225                      {"x-ksc5601-11", "KSC5601", CS_KSC5601_11},
00226                      {"gb2312", "GB2312", CS_GB_8BIT},
00227                      {"gb_2312-80", "GB2312", CS_GB2312},
00228                      {"x-gb2312-11", "GB2312", CS_GB2312_11},
00229                      {"x-euc-tw", "CNS11643", CS_CNS_8BIT},
00230                      {"x-cns11643-1", "CNS11643", CS_CNS11643_1},
00231                      {"x-cns11643-2", "CNS11643", CS_CNS11643_2},
00232                      {"x-cns11643-1110", "CNS11643", CS_CNS11643_1110},
00233                      {"iso-2022-kr", "KSC5601", CS_2022_KR},
00234                      {"big5", "Big5", CS_BIG5},
00235                      {"x-x-big5", "Big5", CS_X_BIG5},
00236                      {"x-tis620", "TIS620", CS_TIS620},
00237                      {"adobe-symbol-encoding", "Symbol", CS_SYMBOL},
00238                      {"x-dingbats", "DingBats", CS_DINGBATS},
00239                      {"x-dectech", "DECTECH", CS_DECTECH},
00240                      {"koi8-r", "KOI8_R", CS_KOI8_R},
00241                      {"x-mac-cyrillic", "MacCyrillic", CS_MAC_CYRILLIC}, 
00242                      {"x-mac-greek", "MacGreek", CS_MAC_GREEK}, 
00243                      {"x-mac-turkish", "MacTurkish", CS_MAC_TURKISH}, 
00244                      {"windows-1250", "Cp1250", CS_CP_1250},
00245                      {"windows-1251", "Cp1251", CS_CP_1251}, /* cyrillic */
00246                      {"windows-1253", "Cp1253", CS_CP_1253},  /* greek */
00247                      {"windows-1257", "Cp1257", CS_CP_1257},  /* baltic */
00248                      {"UTF-8", "UTF8", CS_UTF8},
00249                      {"UTF-7", "UTF7", CS_UTF7},
00250                      {"ISO-10646-UCS-2", "Unicode", CS_UCS2},
00251                      {"ISO-10646-UCS-4", "UCS4", CS_UCS4},
00252                      {"x-imap4-modified-utf7", "", CS_IMAP4_UTF7},
00253                      {"T.61-8bit", "", CS_T61},
00254                      {"HZ-GB-2312", "", CS_HZ},
00255 
00256        /* cP866 support for ibm */
00257                      {"ibm866", "Cp866", CS_CP_866},         /* PC Russian */
00258                      {"cp866", "Cp866", CS_CP_866},          /* PC Russian */
00259 
00260        /* Baltic support for ibm */
00261                      {"windows-1257", "Cp1257", CS_CP_1257},  /* greek */
00262 
00263        /* cP850 support for ibm */
00264                      {"ibm850", "Cp850", CS_CP_850},         /* PC Latin-1 */
00265                      {"cp850", "Cp850", CS_CP_850},          /* PC Latin-1 */
00266 
00267        /* cP852 support for ibm */
00268                      {"ibm852", "Cp852", CS_CP_852},         /* PC Latin-2 */
00269                      {"cp852", "Cp852", CS_CP_852},          /* PC Latin-2 */
00270 
00271        /* cP855 support for ibm */
00272                      {"ibm855", "Cp855", CS_CP_855},         /* PC Cyrillic */
00273                      {"cp855", "Cp855", CS_CP_855},          /* PC Cyrillic */
00274 
00275        /* cP857 support for ibm */
00276                      {"ibm857", "Cp857", CS_CP_857},         /* PC Turkish */
00277                      {"cp857", "Cp857", CS_CP_857},          /* PC Turkish */
00278 
00279        /* cP862 support for ibm */
00280                      {"ibm862", "Cp862", CS_CP_862},         /* PC Hebrew */
00281                      {"cp862", "Cp862", CS_CP_862},          /* PC Hebrew */
00282 
00283        /* cP864 support for ibm */
00284                      {"ibm864", "Cp864", CS_CP_864},         /* PC Arabic */
00285                      {"cp864", "Cp864", CS_CP_864},          /* PC Arabic */
00286 
00287        /* aliases for us-ascii: */
00288                      {"ansi_x3.4-1968", "", CS_ASCII},
00289                      {"iso-ir-6", "", CS_ASCII},
00290                      {"ansi_x3.4-1986", "", CS_ASCII},
00291                      {"iso_646.irv:1991", "", CS_ASCII},
00292                      {"ascii", "", CS_ASCII},
00293                      {"iso646-us", "", CS_ASCII},
00294                      {"us", "", CS_ASCII},
00295                      {"ibm367", "", CS_ASCII},
00296                      {"cp367", "", CS_ASCII},
00297                      {"csASCII", "", CS_ASCII},
00298 
00299        /* aliases for iso_8859-1:  */
00300                      {"latin1", "", CS_LATIN1},
00301                      {"iso_8859-1", "", CS_LATIN1},
00302                      {"iso_8859-1:1987", "", CS_LATIN1},
00303                      {"iso-ir-100", "", CS_LATIN1},
00304                      {"l1", "", CS_LATIN1},
00305                      {"ibm819", "", CS_LATIN1},
00306                      {"cp819", "", CS_LATIN1},
00307                      {"ISO-8859-1-Windows-3.0-Latin-1", "", CS_LATIN1},
00308                      {"ISO-8859-1-Windows-3.1-Latin-1", "", CS_LATIN1},
00309                      {"windows-1252", "", CS_LATIN1},
00310                      {"iso8859-1", "", CS_LATIN1},
00311                      
00312        /* aliases for ISO_8859-2:  */
00313                      {"latin2", "", CS_LATIN2},                
00314                      {"iso_8859-2", "", CS_LATIN2},
00315                      {"iso_8859-2:1987", "", CS_LATIN2},
00316                      {"iso-ir-101", "", CS_LATIN2},
00317                      {"l2", "", CS_LATIN2},                                                                            
00318                      {"ISO-8859-2-Windows-Latin-2", "", CS_LATIN2},
00319 
00320        /* aliases for KS_C_5601-1987:     */
00321                      {"ks_c_5601-1987", "", CS_KSC5601},
00322                      {"iso-ir-149", "", CS_KSC5601},
00323                      {"ks_c_5601-1989", "", CS_KSC5601},
00324                      {"ksc_5601", "", CS_KSC5601},
00325                      {"ks_c_5601", "", CS_KSC5601},
00326                      {"korean", "", CS_KSC5601},
00327                      {"csKSC56011987", "", CS_KSC5601},
00328 
00329        /* aliases for iso-2022-kr: */
00330                      {"csISO2022KR", "", CS_2022_KR},
00331 
00332        /* aliases for euc-kr:      */
00333                      {"csEUCKR", "", CS_KSC_8BIT},
00334                      {"ksc5601", "", CS_KSC_8BIT},
00335 
00336        /* aliases for iso-2022-jp: */
00337                      {"csISO2022JP", "", CS_JIS},
00338 
00339        /* aliases for iso-2022-jp-2:      */
00340                      {"csISO2022JP2", "", CS_JIS},
00341 
00342        /* aliases for GB_2312-80:  */
00343                      {"iso-ir-58", "", CS_GB2312},
00344                      {"chinese", "", CS_GB2312},
00345                      {"csISO58GB231280", "", CS_GB2312},
00346 
00347        /* aliases for gb2312:      */
00348                      {"csGB2312", "", CS_GB_8BIT},
00349                      {"CN-GB", "", CS_GB_8BIT},  /* Simplified Chinese */
00350                      {"CN-GB-ISOIR165", "", CS_GB_8BIT},  /* Simplified Chinese */
00351 
00352        /* aliases for big5: */
00353                      {"csBig5", "", CS_BIG5},
00354                      {"CN-Big5", "", CS_BIG5},  /* Traditional Chinese */
00355 
00356        /* aliases for iso-8859-7:  */
00357                      {"iso-ir-126", "", CS_8859_7},
00358                      {"iso_8859-7", "", CS_8859_7},
00359                      {"iso_8859-7:1987", "", CS_8859_7},
00360                      {"elot_928", "", CS_8859_7},
00361                      {"ecma-118", "", CS_8859_7},
00362                      {"greek", "", CS_8859_7},
00363                      {"greek8", "", CS_8859_7},
00364                      {"csISOLatinGreek", "", CS_8859_7},
00365 
00366        /* aliases for iso-8859-5:  */
00367                      {"iso-ir-144", "", CS_8859_5},
00368                      {"iso_8859-5", "", CS_8859_5},
00369                      {"iso_8859-5:1988", "", CS_8859_5},
00370                      {"cyrillic", "", CS_8859_5},
00371                      {"csISOLatinCyrillic", "", CS_8859_5},
00372 
00373        /* aliases for iso-8859-4:  */
00374                      {"iso-ir-110", "", CS_8859_4},
00375                      {"iso_8859-4", "", CS_8859_4},
00376                      {"iso_8859-4:1988", "", CS_8859_4},
00377                      {"latin4", "", CS_8859_4},
00378                      {"l4", "", CS_8859_4},
00379                      {"csISOLatin4", "", CS_8859_4},
00380 
00381        /* aliases for jis_x0212-1990:     */
00382                      {"x0212", "", CS_JISX0212},
00383                      {"iso-ir-159", "", CS_JISX0212},
00384                      {"csISO159JISX02121990", "", CS_JISX0212},
00385 
00386        /* aliases for jis_x0201:   */
00387                      {"x0201", "", CS_JISX0201},
00388                      {"csHalfWidthKatakana", "", CS_JISX0201},
00389 
00390        /* aliases for koi8-r:      */
00391                      {"csKOI8R", "", CS_KOI8_R},
00392 
00393        /* aliases for Shift_JIS:   */
00394                      {"x-sjis", "", CS_SJIS},
00395                      {"ms_Kanji", "", CS_SJIS},
00396                      {"csShiftJIS", "", CS_SJIS},
00397                      {"Windows-31J", "", CS_SJIS},
00398 
00399        /* aliases for x-euc-jp:    */
00400                      {"Extended_UNIX_Code_Packed_Format_for_Japanese", "", CS_EUCJP},
00401                      {"csEUCPkdFmtJapanese", "", CS_EUCJP},
00402                      {"x-euc-jp", "", CS_EUCJP},
00403 
00404        /* aliases for adobe-symbol-encoding:     */
00405                      {"csHPPSMath", "", CS_SYMBOL},
00406 
00407        /* aliases for iso-8859-5-windows-latin-5:       */
00408                      {"csWindows31Latin5", "", CS_CP_1251},
00409                      {"iso-8859-5-windows-latin-5", "", CS_CP_1251},
00410                      {"x-cp1251", "", CS_CP_1251},
00411 
00412        /* aliases for windows-1250:       */
00413                      {"x-cp1250", "", CS_CP_1250},
00414 
00415        /* aliases for windows-1253:       */
00416                      {"x-cp1253", "", CS_CP_1253}, 
00417 
00418        /* aliases for windows-1254:       */
00419                      {"windows-1254", "", CS_8859_9},  /* turkish */
00420 
00421        /* aliases for UNICODE-1-1: */
00422                      {"csUnicode11", "", CS_UCS2},
00423                      {"ISO-10646-UCS-BASIC", "", CS_UCS2},
00424                      {"csUnicodeASCII", "", CS_UCS2},
00425                      {"ISO-10646-Unicode-Latin1", "", CS_UCS2},
00426                      {"csUnicodeLatin1", "", CS_UCS2},
00427                      {"ISO-10646", "", CS_UCS2},
00428                      {"ISO-10646-J-1", "", CS_UCS2},
00429 
00430        /* aliases for UTF-7:       */
00431                      {"x-UNICODE-2-0-UTF-7", "", CS_UTF7},
00432                      {"UNICODE-1-1-UTF-7", "", CS_UTF7},
00433                      {"UNICODE-2-0-UTF-7", "", CS_UTF7},       /* Appeared in UTF-7 RFC Draft */
00434                      {"csUnicode11UTF7", "", CS_UTF7},
00435 
00436        /* aliases for T.61-8bit:   */
00437                      {"T.61", "", CS_T61},
00438                      {"iso-ir-103", "", CS_T61},
00439                      {"csISO103T618bit", "", CS_T61},
00440 
00441        /* aliases for UNICODE-1-1-UTF-8:  */
00442                      {"UNICODE-1-1-UTF-8", "", CS_UTF8},
00443 
00444                      {"x-user-defined", "", CS_USER_DEFINED_ENCODING},                                                                             
00445                      {"x-user-defined", "", CS_USRDEF2},                                                                             
00446 
00447                      {"RESERVED", "", CS_DEFAULT},                    /* or unknown charset              */
00448 
00449                      {"",   "", CS_UNKNOWN}
00450 };
00451 
00452 static const char *INTL_CsidToCharsetNamePt(PRUint16 csid)
00453 {
00454        csname2id_t   *csn2idp;
00455 
00456        csid &= ~CS_AUTO;
00457        csn2idp = &csname2id_tbl[1];       /* First one is reserved, skip it. */
00458        csid &= 0xff;
00459 
00460        /* Linear search for charset string */
00461        while (*(csn2idp->cs_name) != '\0') {
00462               if ((csn2idp->cs_id & 0xff) == csid)
00463                      return csn2idp->cs_name;
00464               csn2idp++;
00465        }
00466        return "";
00467 }
00468 
00470 
00471 extern "C" const char * I18N_CSIDtoCharsetName(PRUint16 csid)
00472 {
00473   const char *charset = INTL_CsidToCharsetNamePt(csid);
00474 
00475   return *charset ? charset : "ISO-8859-1";
00476 }
00477