作者 邓超

x

@@ -39,11 +39,445 @@ class Fun { @@ -39,11 +39,445 @@ class Fun {
39 * @time 2024/10/25 17:24 39 * @time 2024/10/25 17:24
40 */ 40 */
41 public static function getEncodingAliases($coding){ 41 public static function getEncodingAliases($coding){
  42 +
42 $alias = [ 43 $alias = [
43 - "iso-8859-8-i" => "ISO-8859-8",  
44 - "iso-8859-8-e" => "ISO-8859-8", 44 + /*
  45 + |--------------------------------------------------------------------------
  46 + | Email encoding aliases
  47 + |--------------------------------------------------------------------------
  48 + |
  49 + | Email encoding aliases used to convert to iconv supported charsets
  50 + |
  51 + |
  52 + | This Source Code Form is subject to the terms of the Mozilla Public
  53 + | License, v. 2.0. If a copy of the MPL was not distributed with this
  54 + | file, You can obtain one at http://mozilla.org/MPL/2.0/.
  55 + |
  56 + | This Original Code has been modified by IBM Corporation.
  57 + | Modifications made by IBM described herein are
  58 + | Copyright (c) International Business Machines
  59 + | Corporation, 1999
  60 + |
  61 + | Modifications to Mozilla code or documentation
  62 + | identified per MPL Section 3.3
  63 + |
  64 + | Date Modified by Description of modification
  65 + | 12/09/1999 IBM Corp. Support for IBM codepages - 850,852,855,857,862,864
  66 + |
  67 + | Rule of this file:
  68 + | 1. key should always be in lower case ascii so we can do case insensitive
  69 + | comparison in the code faster.
  70 + | 2. value should be the one used in unicode converter
  71 + |
  72 + | 3. If the charset is not used for document charset, but font charset
  73 + | (e.g. XLFD charset- such as JIS x0201, JIS x0208), don't put here
  74 + |
  75 + */
  76 + "ascii" => "us-ascii",
  77 + "us-ascii" => "us-ascii",
  78 + "ansi_x3.4-1968" => "us-ascii",
  79 + "646" => "us-ascii",
  80 + "iso-8859-1" => "ISO-8859-1",
  81 + "iso-8859-2" => "ISO-8859-2",
  82 + "iso-8859-3" => "ISO-8859-3",
  83 + "iso-8859-4" => "ISO-8859-4",
  84 + "iso-8859-5" => "ISO-8859-5",
  85 + "iso-8859-6" => "ISO-8859-6",
45 "iso-8859-6-i" => "ISO-8859-6", 86 "iso-8859-6-i" => "ISO-8859-6",
46 "iso-8859-6-e" => "ISO-8859-6", 87 "iso-8859-6-e" => "ISO-8859-6",
  88 + "iso-8859-7" => "ISO-8859-7",
  89 + "iso-8859-8" => "ISO-8859-8",
  90 + "iso-8859-8-i" => "ISO-8859-8",
  91 + "iso-8859-8-e" => "ISO-8859-8",
  92 + "iso-8859-9" => "ISO-8859-9",
  93 + "iso-8859-10" => "ISO-8859-10",
  94 + "iso-8859-11" => "ISO-8859-11",
  95 + "iso-8859-13" => "ISO-8859-13",
  96 + "iso-8859-14" => "ISO-8859-14",
  97 + "iso-8859-15" => "ISO-8859-15",
  98 + "iso-8859-16" => "ISO-8859-16",
  99 + "iso-ir-111" => "ISO-IR-111",
  100 + "iso-2022-cn" => "ISO-2022-CN",
  101 + "iso-2022-cn-ext" => "ISO-2022-CN",
  102 + "iso-2022-kr" => "ISO-2022-KR",
  103 + "iso-2022-jp" => "ISO-2022-JP",
  104 + "utf-16be" => "UTF-16BE",
  105 + "utf-16le" => "UTF-16LE",
  106 + "utf-16" => "UTF-16",
  107 + "windows-1250" => "windows-1250",
  108 + "windows-1251" => "windows-1251",
  109 + "windows-1252" => "windows-1252",
  110 + "windows-1253" => "windows-1253",
  111 + "windows-1254" => "windows-1254",
  112 + "windows-1255" => "windows-1255",
  113 + "windows-1256" => "windows-1256",
  114 + "windows-1257" => "windows-1257",
  115 + "windows-1258" => "windows-1258",
  116 + "ibm866" => "IBM866",
  117 + "ibm850" => "IBM850",
  118 + "ibm852" => "IBM852",
  119 + "ibm855" => "IBM855",
  120 + "ibm857" => "IBM857",
  121 + "ibm862" => "IBM862",
  122 + "ibm864" => "IBM864",
  123 + "utf-8" => "UTF-8",
  124 + "utf-7" => "UTF-7",
  125 + "shift_jis" => "Shift_JIS",
  126 + "big5" => "Big5",
  127 + "euc-jp" => "EUC-JP",
  128 + "euc-kr" => "EUC-KR",
  129 + "gb2312" => "GB2312",
  130 + "gb18030" => "gb18030",
  131 + "viscii" => "VISCII",
  132 + "koi8-r" => "KOI8-R",
  133 + "koi8_r" => "KOI8-R",
  134 + "cskoi8r" => "KOI8-R",
  135 + "koi" => "KOI8-R",
  136 + "koi8" => "KOI8-R",
  137 + "koi8-u" => "KOI8-U",
  138 + "tis-620" => "TIS-620",
  139 + "t.61-8bit" => "T.61-8bit",
  140 + "hz-gb-2312" => "HZ-GB-2312",
  141 + "big5-hkscs" => "Big5-HKSCS",
  142 + "gbk" => "gbk",
  143 + "cns11643" => "x-euc-tw",
  144 + //
  145 + // Aliases for ISO-8859-1
  146 + //
  147 + "latin1" => "ISO-8859-1",
  148 + "iso_8859-1" => "ISO-8859-1",
  149 + "iso8859-1" => "ISO-8859-1",
  150 + "iso8859-2" => "ISO-8859-2",
  151 + "iso8859-3" => "ISO-8859-3",
  152 + "iso8859-4" => "ISO-8859-4",
  153 + "iso8859-5" => "ISO-8859-5",
  154 + "iso8859-6" => "ISO-8859-6",
  155 + "iso8859-7" => "ISO-8859-7",
  156 + "iso8859-8" => "ISO-8859-8",
  157 + "iso8859-9" => "ISO-8859-9",
  158 + "iso8859-10" => "ISO-8859-10",
  159 + "iso8859-11" => "ISO-8859-11",
  160 + "iso8859-13" => "ISO-8859-13",
  161 + "iso8859-14" => "ISO-8859-14",
  162 + "iso8859-15" => "ISO-8859-15",
  163 + "iso_8859-1:1987" => "ISO-8859-1",
  164 + "iso-ir-100" => "ISO-8859-1",
  165 + "l1" => "ISO-8859-1",
  166 + "ibm819" => "ISO-8859-1",
  167 + "cp819" => "ISO-8859-1",
  168 + "csisolatin1" => "ISO-8859-1",
  169 + //
  170 + // Aliases for ISO-8859-2
  171 + //
  172 + "latin2" => "ISO-8859-2",
  173 + "iso_8859-2" => "ISO-8859-2",
  174 + "iso_8859-2:1987" => "ISO-8859-2",
  175 + "iso-ir-101" => "ISO-8859-2",
  176 + "l2" => "ISO-8859-2",
  177 + "csisolatin2" => "ISO-8859-2",
  178 + //
  179 + // Aliases for ISO-8859-3
  180 + //
  181 + "latin3" => "ISO-8859-3",
  182 + "iso_8859-3" => "ISO-8859-3",
  183 + "iso_8859-3:1988" => "ISO-8859-3",
  184 + "iso-ir-109" => "ISO-8859-3",
  185 + "l3" => "ISO-8859-3",
  186 + "csisolatin3" => "ISO-8859-3",
  187 + //
  188 + // Aliases for ISO-8859-4
  189 + //
  190 + "latin4" => "ISO-8859-4",
  191 + "iso_8859-4" => "ISO-8859-4",
  192 + "iso_8859-4:1988" => "ISO-8859-4",
  193 + "iso-ir-110" => "ISO-8859-4",
  194 + "l4" => "ISO-8859-4",
  195 + "csisolatin4" => "ISO-8859-4",
  196 + //
  197 + // Aliases for ISO-8859-5
  198 + //
  199 + "cyrillic" => "ISO-8859-5",
  200 + "iso_8859-5" => "ISO-8859-5",
  201 + "iso_8859-5:1988" => "ISO-8859-5",
  202 + "iso-ir-144" => "ISO-8859-5",
  203 + "csisolatincyrillic" => "ISO-8859-5",
  204 + //
  205 + // Aliases for ISO-8859-6
  206 + //
  207 + "arabic" => "ISO-8859-6",
  208 + "iso_8859-6" => "ISO-8859-6",
  209 + "iso_8859-6:1987" => "ISO-8859-6",
  210 + "iso-ir-127" => "ISO-8859-6",
  211 + "ecma-114" => "ISO-8859-6",
  212 + "asmo-708" => "ISO-8859-6",
  213 + "csisolatinarabic" => "ISO-8859-6",
  214 + //
  215 + // Aliases for ISO-8859-6-I
  216 + //
  217 + "csiso88596i" => "ISO-8859-6",
  218 + //
  219 + // Aliases for ISO-8859-6-E",
  220 + //
  221 + "csiso88596e" => "ISO-8859-6",
  222 + //
  223 + // Aliases for ISO-8859-7",
  224 + //
  225 + "greek" => "ISO-8859-7",
  226 + "greek8" => "ISO-8859-7",
  227 + "sun_eu_greek" => "ISO-8859-7",
  228 + "iso_8859-7" => "ISO-8859-7",
  229 + "iso_8859-7:1987" => "ISO-8859-7",
  230 + "iso-ir-126" => "ISO-8859-7",
  231 + "elot_928" => "ISO-8859-7",
  232 + "ecma-118" => "ISO-8859-7",
  233 + "csisolatingreek" => "ISO-8859-7",
  234 + //
  235 + // Aliases for ISO-8859-8",
  236 + //
  237 + "hebrew" => "ISO-8859-8",
  238 + "iso_8859-8" => "ISO-8859-8",
  239 + "visual" => "ISO-8859-8",
  240 + "iso_8859-8:1988" => "ISO-8859-8",
  241 + "iso-ir-138" => "ISO-8859-8",
  242 + "csisolatinhebrew" => "ISO-8859-8",
  243 + //
  244 + // Aliases for ISO-8859-8-I",
  245 + //
  246 + "csiso88598i" => "ISO-8859-8",
  247 + "iso-8859-8i" => "ISO-8859-8",
  248 + "logical" => "ISO-8859-8",
  249 + //
  250 + // Aliases for ISO-8859-8-E",
  251 + //
  252 + "csiso88598e" => "ISO-8859-8",
  253 + //
  254 + // Aliases for ISO-8859-9",
  255 + //
  256 + "latin5" => "ISO-8859-9",
  257 + "iso_8859-9" => "ISO-8859-9",
  258 + "iso_8859-9:1989" => "ISO-8859-9",
  259 + "iso-ir-148" => "ISO-8859-9",
  260 + "l5" => "ISO-8859-9",
  261 + "csisolatin5" => "ISO-8859-9",
  262 + //
  263 + // Aliases for UTF-8",
  264 + //
  265 + "unicode-1-1-utf-8" => "UTF-8",
  266 + // nl_langinfo(CODESET) in HP/UX returns 'utf8' under UTF-8 locales",
  267 + "utf8" => "UTF-8",
  268 + //
  269 + // Aliases for Shift_JIS",
  270 + //
  271 + "x-sjis" => "Shift_JIS",
  272 + "shift-jis" => "Shift_JIS",
  273 + "ms_kanji" => "Shift_JIS",
  274 + "csshiftjis" => "Shift_JIS",
  275 + "windows-31j" => "Shift_JIS",
  276 + "cp932" => "Shift_JIS",
  277 + "sjis" => "Shift_JIS",
  278 + //
  279 + // Aliases for EUC_JP",
  280 + //
  281 + "cseucpkdfmtjapanese" => "EUC-JP",
  282 + "x-euc-jp" => "EUC-JP",
  283 + //
  284 + // Aliases for ISO-2022-JP",
  285 + //
  286 + "csiso2022jp" => "ISO-2022-JP",
  287 + // The following are really not aliases ISO-2022-JP, but sharing the same decoder",
  288 + "iso-2022-jp-2" => "ISO-2022-JP",
  289 + "csiso2022jp2" => "ISO-2022-JP",
  290 + //
  291 + // Aliases for Big5",
  292 + //
  293 + "csbig5" => "Big5",
  294 + "cn-big5" => "Big5",
  295 + // x-x-big5 is not really a alias for Big5, add it only for MS FrontPage",
  296 + "x-x-big5" => "Big5",
  297 + // Sun Solaris",
  298 + "zh_tw-big5" => "Big5",
  299 + //
  300 + // Aliases for EUC-KR",
  301 + //
  302 + "cseuckr" => "EUC-KR",
  303 + "ks_c_5601-1987" => "EUC-KR",
  304 + "iso-ir-149" => "EUC-KR",
  305 + "ks_c_5601-1989" => "EUC-KR",
  306 + "ksc_5601" => "EUC-KR",
  307 + "ksc5601" => "EUC-KR",
  308 + "korean" => "EUC-KR",
  309 + "csksc56011987" => "EUC-KR",
  310 + "5601" => "EUC-KR",
  311 + "windows-949" => "EUC-KR",
  312 + //
  313 + // Aliases for GB2312",
  314 + //
  315 + // The following are really not aliases GB2312, add them only for MS FrontPage",
  316 + "gb_2312-80" => "GB2312",
  317 + "iso-ir-58" => "GB2312",
  318 + "chinese" => "GB2312",
  319 + "csiso58gb231280" => "GB2312",
  320 + "csgb2312" => "GB2312",
  321 + "zh_cn.euc" => "GB2312",
  322 + // Sun Solaris",
  323 + "gb_2312" => "GB2312",
  324 + //
  325 + // Aliases for windows-125x ",
  326 + //
  327 + "x-cp1250" => "windows-1250",
  328 + "x-cp1251" => "windows-1251",
  329 + "x-cp1252" => "windows-1252",
  330 + "x-cp1253" => "windows-1253",
  331 + "x-cp1254" => "windows-1254",
  332 + "x-cp1255" => "windows-1255",
  333 + "x-cp1256" => "windows-1256",
  334 + "x-cp1257" => "windows-1257",
  335 + "x-cp1258" => "windows-1258",
  336 + //
  337 + // Aliases for windows-874 ",
  338 + //
  339 + "windows-874" => "windows-874",
  340 + "ibm874" => "windows-874",
  341 + "dos-874" => "windows-874",
  342 + //
  343 + // Aliases for macintosh",
  344 + //
  345 + "macintosh" => "macintosh",
  346 + "x-mac-roman" => "macintosh",
  347 + "mac" => "macintosh",
  348 + "csmacintosh" => "macintosh",
  349 + //
  350 + // Aliases for IBM866",
  351 + //
  352 + "cp866" => "IBM866",
  353 + "cp-866" => "IBM866",
  354 + "866" => "IBM866",
  355 + "csibm866" => "IBM866",
  356 + //
  357 + // Aliases for IBM850",
  358 + //
  359 + "cp850" => "IBM850",
  360 + "850" => "IBM850",
  361 + "csibm850" => "IBM850",
  362 + //
  363 + // Aliases for IBM852",
  364 + //
  365 + "cp852" => "IBM852",
  366 + "852" => "IBM852",
  367 + "csibm852" => "IBM852",
  368 + //
  369 + // Aliases for IBM855",
  370 + //
  371 + "cp855" => "IBM855",
  372 + "855" => "IBM855",
  373 + "csibm855" => "IBM855",
  374 + //
  375 + // Aliases for IBM857",
  376 + //
  377 + "cp857" => "IBM857",
  378 + "857" => "IBM857",
  379 + "csibm857" => "IBM857",
  380 + //
  381 + // Aliases for IBM862",
  382 + //
  383 + "cp862" => "IBM862",
  384 + "862" => "IBM862",
  385 + "csibm862" => "IBM862",
  386 + //
  387 + // Aliases for IBM864",
  388 + //
  389 + "cp864" => "IBM864",
  390 + "864" => "IBM864",
  391 + "csibm864" => "IBM864",
  392 + "ibm-864" => "IBM864",
  393 + //
  394 + // Aliases for T.61-8bit",
  395 + //
  396 + "t.61" => "T.61-8bit",
  397 + "iso-ir-103" => "T.61-8bit",
  398 + "csiso103t618bit" => "T.61-8bit",
  399 + //
  400 + // Aliases for UTF-7",
  401 + //
  402 + "x-unicode-2-0-utf-7" => "UTF-7",
  403 + "unicode-2-0-utf-7" => "UTF-7",
  404 + "unicode-1-1-utf-7" => "UTF-7",
  405 + "csunicode11utf7" => "UTF-7",
  406 + //
  407 + // Aliases for ISO-10646-UCS-2",
  408 + //
  409 + "csunicode" => "UTF-16BE",
  410 + "csunicode11" => "UTF-16BE",
  411 + "iso-10646-ucs-basic" => "UTF-16BE",
  412 + "csunicodeascii" => "UTF-16BE",
  413 + "iso-10646-unicode-latin1" => "UTF-16BE",
  414 + "csunicodelatin1" => "UTF-16BE",
  415 + "iso-10646" => "UTF-16BE",
  416 + "iso-10646-j-1" => "UTF-16BE",
  417 + //
  418 + // Aliases for ISO-8859-10",
  419 + //
  420 + "latin6" => "ISO-8859-10",
  421 + "iso-ir-157" => "ISO-8859-10",
  422 + "l6" => "ISO-8859-10",
  423 + // Currently .properties cannot handle : in key",
  424 + //iso_8859-10:1992" => "ISO-8859-10",
  425 + "csisolatin6" => "ISO-8859-10",
  426 + //
  427 + // Aliases for ISO-8859-15",
  428 + //
  429 + "iso_8859-15" => "ISO-8859-15",
  430 + "csisolatin9" => "ISO-8859-15",
  431 + "l9" => "ISO-8859-15",
  432 + //
  433 + // Aliases for ISO-IR-111",
  434 + //
  435 + "ecma-cyrillic" => "ISO-IR-111",
  436 + "csiso111ecmacyrillic" => "ISO-IR-111",
  437 + //
  438 + // Aliases for ISO-2022-KR",
  439 + //
  440 + "csiso2022kr" => "ISO-2022-KR",
  441 + //
  442 + // Aliases for VISCII",
  443 + //
  444 + "csviscii" => "VISCII",
  445 + //
  446 + // Aliases for x-euc-tw",
  447 + //
  448 + "zh_tw-euc" => "x-euc-tw",
  449 + //
  450 + // Following names appears in unix nl_langinfo(CODESET)",
  451 + // They can be compiled as platform specific if necessary",
  452 + // DONT put things here if it does not look generic enough (like hp15CN)",
  453 + //
  454 + "iso88591" => "ISO-8859-1",
  455 + "iso88592" => "ISO-8859-2",
  456 + "iso88593" => "ISO-8859-3",
  457 + "iso88594" => "ISO-8859-4",
  458 + "iso88595" => "ISO-8859-5",
  459 + "iso88596" => "ISO-8859-6",
  460 + "iso88597" => "ISO-8859-7",
  461 + "iso88598" => "ISO-8859-8",
  462 + "iso88599" => "ISO-8859-9",
  463 + "iso885910" => "ISO-8859-10",
  464 + "iso885911" => "ISO-8859-11",
  465 + "iso885912" => "ISO-8859-12",
  466 + "iso885913" => "ISO-8859-13",
  467 + "iso885914" => "ISO-8859-14",
  468 + "iso885915" => "ISO-8859-15",
  469 + "cp1250" => "windows-1250",
  470 + "cp1251" => "windows-1251",
  471 + "cp1252" => "windows-1252",
  472 + "cp1253" => "windows-1253",
  473 + "cp1254" => "windows-1254",
  474 + "cp1255" => "windows-1255",
  475 + "cp1256" => "windows-1256",
  476 + "cp1257" => "windows-1257",
  477 + "cp1258" => "windows-1258",
  478 + "x-gbk" => "gbk",
  479 + "windows-936" => "gbk",
  480 + "ansi-1251" => "windows-1251",
47 ]; 481 ];
48 482
49 $coding = strtolower($coding); 483 $coding = strtolower($coding);