Просмотр исходного кода

Adding decoding support for two DOSCyr charsets and several x-mac-* charsets.
Information is taken from ftp.unicode.org

tokul 22 лет назад
Родитель
Сommit
e94ae2d43f

+ 170 - 0
functions/decode/cp10000.php

@@ -0,0 +1,170 @@
+<?php
+/*
+ * decode/cp10000.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp10000 (MacRoman) decoding function that 
+ * is needed to read cp10000 encoded mails in non-cp10000 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/ROMAN.TXT
+ *
+ *  Name:     cp10000_MacRoman to Unicode table
+ *  Unicode version: 2.0
+ *  Table version: 2.00
+ *  Table format:  Format A
+ *  Date:          04/24/96
+ *  Authors:       Lori Brownell <loribr@microsoft.com>
+ *                 K.D. Chang    <a-kchang@microsoft.com>
+ */
+
+function charset_decode_cp10000 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'x-mac-roman')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp10000 = array(
+	"\0x80" => '&#196;',
+	"\0x81" => '&#197;',
+	"\0x82" => '&#199;',
+	"\0x83" => '&#201;',
+	"\0x84" => '&#209;',
+	"\0x85" => '&#214;',
+	"\0x86" => '&#220;',
+	"\0x87" => '&#225;',
+	"\0x88" => '&#224;',
+	"\0x89" => '&#226;',
+	"\0x8A" => '&#228;',
+	"\0x8B" => '&#227;',
+	"\0x8C" => '&#229;',
+	"\0x8D" => '&#231;',
+	"\0x8E" => '&#233;',
+	"\0x8F" => '&#232;',
+	"\0x90" => '&#234;',
+	"\0x91" => '&#235;',
+	"\0x92" => '&#237;',
+	"\0x93" => '&#236;',
+	"\0x94" => '&#238;',
+	"\0x95" => '&#239;',
+	"\0x96" => '&#241;',
+	"\0x97" => '&#243;',
+	"\0x98" => '&#242;',
+	"\0x99" => '&#244;',
+	"\0x9A" => '&#246;',
+	"\0x9B" => '&#245;',
+	"\0x9C" => '&#250;',
+	"\0x9D" => '&#249;',
+	"\0x9E" => '&#251;',
+	"\0x9F" => '&#252;',
+	"\0xA0" => '&#8224;',
+	"\0xA1" => '&#176;',
+	"\0xA2" => '&#162;',
+	"\0xA3" => '&#163;',
+	"\0xA4" => '&#167;',
+	"\0xA5" => '&#8226;',
+	"\0xA6" => '&#182;',
+	"\0xA7" => '&#223;',
+	"\0xA8" => '&#174;',
+	"\0xA9" => '&#169;',
+	"\0xAA" => '&#8482;',
+	"\0xAB" => '&#180;',
+	"\0xAC" => '&#168;',
+	"\0xAD" => '&#8800;',
+	"\0xAE" => '&#198;',
+	"\0xAF" => '&#216;',
+	"\0xB0" => '&#8734;',
+	"\0xB1" => '&#177;',
+	"\0xB2" => '&#8804;',
+	"\0xB3" => '&#8805;',
+	"\0xB4" => '&#165;',
+	"\0xB5" => '&#181;',
+	"\0xB6" => '&#8706;',
+	"\0xB7" => '&#8721;',
+	"\0xB8" => '&#8719;',
+	"\0xB9" => '&#960;',
+	"\0xBA" => '&#8747;',
+	"\0xBB" => '&#170;',
+	"\0xBC" => '&#186;',
+	"\0xBD" => '&#8486;',
+	"\0xBE" => '&#230;',
+	"\0xBF" => '&#248;',
+	"\0xC0" => '&#191;',
+	"\0xC1" => '&#161;',
+	"\0xC2" => '&#172;',
+	"\0xC3" => '&#8730;',
+	"\0xC4" => '&#402;',
+	"\0xC5" => '&#8776;',
+	"\0xC6" => '&#8710;',
+	"\0xC7" => '&#171;',
+	"\0xC8" => '&#187;',
+	"\0xC9" => '&#8230;',
+	"\0xCA" => '&#160;',
+	"\0xCB" => '&#192;',
+	"\0xCC" => '&#195;',
+	"\0xCD" => '&#213;',
+	"\0xCE" => '&#338;',
+	"\0xCF" => '&#339;',
+	"\0xD0" => '&#8211;',
+	"\0xD1" => '&#8212;',
+	"\0xD2" => '&#8220;',
+	"\0xD3" => '&#8221;',
+	"\0xD4" => '&#8216;',
+	"\0xD5" => '&#8217;',
+	"\0xD6" => '&#247;',
+	"\0xD7" => '&#9674;',
+	"\0xD8" => '&#255;',
+	"\0xD9" => '&#376;',
+	"\0xDA" => '&#8260;',
+	"\0xDB" => '&#164;',
+	"\0xDC" => '&#8249;',
+	"\0xDD" => '&#8250;',
+	"\0xDE" => '&#64257;',
+	"\0xDF" => '&#64258;',
+	"\0xE0" => '&#8225;',
+	"\0xE1" => '&#183;',
+	"\0xE2" => '&#8218;',
+	"\0xE3" => '&#8222;',
+	"\0xE4" => '&#8240;',
+	"\0xE5" => '&#194;',
+	"\0xE6" => '&#202;',
+	"\0xE7" => '&#193;',
+	"\0xE8" => '&#203;',
+	"\0xE9" => '&#200;',
+	"\0xEA" => '&#205;',
+	"\0xEB" => '&#206;',
+	"\0xEC" => '&#207;',
+	"\0xED" => '&#204;',
+	"\0xEE" => '&#211;',
+	"\0xEF" => '&#212;',
+	"\0xF0" => '&#65535;',
+	"\0xF1" => '&#210;',
+	"\0xF2" => '&#218;',
+	"\0xF3" => '&#219;',
+	"\0xF4" => '&#217;',
+	"\0xF5" => '&#305;',
+	"\0xF6" => '&#710;',
+	"\0xF7" => '&#732;',
+	"\0xF8" => '&#175;',
+	"\0xF9" => '&#728;',
+	"\0xFA" => '&#729;',
+	"\0xFB" => '&#730;',
+	"\0xFC" => '&#184;',
+	"\0xFD" => '&#733;',
+	"\0xFE" => '&#731;',
+	"\0xFF" => '&#711;'
+    );
+
+    $string = str_replace(array_keys($cp10000), array_values($cp10000), $string);
+
+    return $string;
+}
+?>

+ 170 - 0
functions/decode/cp10006.php

@@ -0,0 +1,170 @@
+<?php
+/*
+ * decode/cp10006.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp10006 (MacGreek) decoding function that 
+ * is needed to read cp10006 encoded mails in non-cp10006 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/GREEK.TXT
+ *
+ *  Name:     cp10006_MacGreek to Unicode table
+ *  Unicode version: 2.0
+ *  Table version: 2.00
+ *  Table format:  Format A
+ *  Date:          04/24/96
+ *  Authors:       Lori Brownell <loribr@microsoft.com>
+ *                 K.D. Chang    <a-kchang@microsoft.com>
+ */
+
+function charset_decode_cp10006 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'x-mac-greek')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp10006 = array(
+	"\0x80" => '&#196;',
+	"\0x81" => '&#185;',
+	"\0x82" => '&#178;',
+	"\0x83" => '&#201;',
+	"\0x84" => '&#179;',
+	"\0x85" => '&#214;',
+	"\0x86" => '&#220;',
+	"\0x87" => '&#901;',
+	"\0x88" => '&#224;',
+	"\0x89" => '&#226;',
+	"\0x8A" => '&#228;',
+	"\0x8B" => '&#900;',
+	"\0x8C" => '&#168;',
+	"\0x8D" => '&#231;',
+	"\0x8E" => '&#233;',
+	"\0x8F" => '&#232;',
+	"\0x90" => '&#234;',
+	"\0x91" => '&#235;',
+	"\0x92" => '&#163;',
+	"\0x93" => '&#8482;',
+	"\0x94" => '&#238;',
+	"\0x95" => '&#239;',
+	"\0x96" => '&#8226;',
+	"\0x97" => '&#189;',
+	"\0x98" => '&#8240;',
+	"\0x99" => '&#244;',
+	"\0x9A" => '&#246;',
+	"\0x9B" => '&#166;',
+	"\0x9C" => '&#173;',
+	"\0x9D" => '&#249;',
+	"\0x9E" => '&#251;',
+	"\0x9F" => '&#252;',
+	"\0xA0" => '&#8224;',
+	"\0xA1" => '&#915;',
+	"\0xA2" => '&#916;',
+	"\0xA3" => '&#920;',
+	"\0xA4" => '&#923;',
+	"\0xA5" => '&#926;',
+	"\0xA6" => '&#928;',
+	"\0xA7" => '&#223;',
+	"\0xA8" => '&#174;',
+	"\0xA9" => '&#169;',
+	"\0xAA" => '&#931;',
+	"\0xAB" => '&#938;',
+	"\0xAC" => '&#167;',
+	"\0xAD" => '&#8800;',
+	"\0xAE" => '&#176;',
+	"\0xAF" => '&#903;',
+	"\0xB0" => '&#913;',
+	"\0xB1" => '&#177;',
+	"\0xB2" => '&#8804;',
+	"\0xB3" => '&#8805;',
+	"\0xB4" => '&#165;',
+	"\0xB5" => '&#914;',
+	"\0xB6" => '&#917;',
+	"\0xB7" => '&#918;',
+	"\0xB8" => '&#919;',
+	"\0xB9" => '&#921;',
+	"\0xBA" => '&#922;',
+	"\0xBB" => '&#924;',
+	"\0xBC" => '&#934;',
+	"\0xBD" => '&#939;',
+	"\0xBE" => '&#936;',
+	"\0xBF" => '&#937;',
+	"\0xC0" => '&#940;',
+	"\0xC1" => '&#925;',
+	"\0xC2" => '&#172;',
+	"\0xC3" => '&#927;',
+	"\0xC4" => '&#929;',
+	"\0xC5" => '&#8776;',
+	"\0xC6" => '&#932;',
+	"\0xC7" => '&#171;',
+	"\0xC8" => '&#187;',
+	"\0xC9" => '&#8230;',
+	"\0xCA" => '&#160;',
+	"\0xCB" => '&#933;',
+	"\0xCC" => '&#935;',
+	"\0xCD" => '&#902;',
+	"\0xCE" => '&#904;',
+	"\0xCF" => '&#339;',
+	"\0xD0" => '&#8211;',
+	"\0xD1" => '&#8213;',
+	"\0xD2" => '&#8220;',
+	"\0xD3" => '&#8221;',
+	"\0xD4" => '&#8216;',
+	"\0xD5" => '&#8217;',
+	"\0xD6" => '&#247;',
+	"\0xD7" => '&#905;',
+	"\0xD8" => '&#906;',
+	"\0xD9" => '&#908;',
+	"\0xDA" => '&#910;',
+	"\0xDB" => '&#941;',
+	"\0xDC" => '&#942;',
+	"\0xDD" => '&#943;',
+	"\0xDE" => '&#972;',
+	"\0xDF" => '&#911;',
+	"\0xE0" => '&#973;',
+	"\0xE1" => '&#945;',
+	"\0xE2" => '&#946;',
+	"\0xE3" => '&#968;',
+	"\0xE4" => '&#948;',
+	"\0xE5" => '&#949;',
+	"\0xE6" => '&#966;',
+	"\0xE7" => '&#947;',
+	"\0xE8" => '&#951;',
+	"\0xE9" => '&#953;',
+	"\0xEA" => '&#958;',
+	"\0xEB" => '&#954;',
+	"\0xEC" => '&#955;',
+	"\0xED" => '&#956;',
+	"\0xEE" => '&#957;',
+	"\0xEF" => '&#959;',
+	"\0xF0" => '&#960;',
+	"\0xF1" => '&#974;',
+	"\0xF2" => '&#961;',
+	"\0xF3" => '&#963;',
+	"\0xF4" => '&#964;',
+	"\0xF5" => '&#952;',
+	"\0xF6" => '&#969;',
+	"\0xF7" => '&#962;',
+	"\0xF8" => '&#967;',
+	"\0xF9" => '&#965;',
+	"\0xFA" => '&#950;',
+	"\0xFB" => '&#970;',
+	"\0xFC" => '&#971;',
+	"\0xFD" => '&#912;',
+	"\0xFE" => '&#944;',
+	"\0xFF" => '&#65535;'
+   );
+
+    $string = str_replace(array_keys($cp10006), array_values($cp10006), $string);
+
+    return $string;
+}
+?>

+ 171 - 0
functions/decode/cp10007.php

@@ -0,0 +1,171 @@
+<?php
+/*
+ * decode/cp10007.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp10007 (MacCyrillic) decoding function that 
+ * is needed to read cp10007 encoded mails in non-cp10007 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/CYRILLIC.TXT
+ *
+ *   Name:     cp10007_MacCyrillic to Unicode table
+ *   Unicode version: 2.0
+ *   Table version: 2.00
+ *   Table format:  Format A
+ *   Date:          04/24/96
+ *   Authors:       Lori Brownell <loribr@microsoft.com>
+ *          K.D. Chang    <a-kchang@microsoft.com>
+ *
+ */
+
+function charset_decode_cp10007 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'x-mac-cyrillic')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp10007 = array(
+	"\x80" => '&#1040;',
+	"\x81" => '&#1041;',
+	"\x82" => '&#1042;',
+	"\x83" => '&#1043;',
+	"\x84" => '&#1044;',
+	"\x85" => '&#1045;',
+	"\x86" => '&#1046;',
+	"\x87" => '&#1047;',
+	"\x88" => '&#1048;',
+	"\x89" => '&#1049;',
+	"\x8A" => '&#1050;',
+	"\x8B" => '&#1051;',
+	"\x8C" => '&#1052;',
+	"\x8D" => '&#1053;',
+	"\x8E" => '&#1054;',
+	"\x8F" => '&#1055;',
+	"\x90" => '&#1056;',
+	"\x91" => '&#1057;',
+	"\x92" => '&#1058;',
+	"\x93" => '&#1059;',
+	"\x94" => '&#1060;',
+	"\x95" => '&#1061;',
+	"\x96" => '&#1062;',
+	"\x97" => '&#1063;',
+	"\x98" => '&#1064;',
+	"\x99" => '&#1065;',
+	"\x9A" => '&#1066;',
+	"\x9B" => '&#1067;',
+	"\x9C" => '&#1068;',
+	"\x9D" => '&#1069;',
+	"\x9E" => '&#1070;',
+	"\x9F" => '&#1071;',
+	"\xA0" => '&#8224;',
+	"\xA1" => '&#176;',
+	"\xA2" => '&#162;',
+	"\xA3" => '&#163;',
+	"\xA4" => '&#167;',
+	"\xA5" => '&#8226;',
+	"\xA6" => '&#182;',
+	"\xA7" => '&#1030;',
+	"\xA8" => '&#174;',
+	"\xA9" => '&#169;',
+	"\xAA" => '&#8482;',
+	"\xAB" => '&#1026;',
+	"\xAC" => '&#1106;',
+	"\xAD" => '&#8800;',
+	"\xAE" => '&#1027;',
+	"\xAF" => '&#1107;',
+	"\xB0" => '&#8734;',
+	"\xB1" => '&#177;',
+	"\xB2" => '&#8804;',
+	"\xB3" => '&#8805;',
+	"\xB4" => '&#1110;',
+	"\xB5" => '&#181;',
+	"\xB6" => '&#8706;',
+	"\xB7" => '&#1032;',
+	"\xB8" => '&#1028;',
+	"\xB9" => '&#1108;',
+	"\xBA" => '&#1031;',
+	"\xBB" => '&#1111;',
+	"\xBC" => '&#1033;',
+	"\xBD" => '&#1113;',
+	"\xBE" => '&#1034;',
+	"\xBF" => '&#1114;',
+	"\xC0" => '&#1112;',
+	"\xC1" => '&#1029;',
+	"\xC2" => '&#172;',
+	"\xC3" => '&#8730;',
+	"\xC4" => '&#402;',
+	"\xC5" => '&#8776;',
+	"\xC6" => '&#8710;',
+	"\xC7" => '&#171;',
+	"\xC8" => '&#187;',
+	"\xC9" => '&#8230;',
+	"\xCA" => '&#160;',
+	"\xCB" => '&#1035;',
+	"\xCC" => '&#1115;',
+	"\xCD" => '&#1036;',
+	"\xCE" => '&#1116;',
+	"\xCF" => '&#1109;',
+	"\xD0" => '&#8211;',
+	"\xD1" => '&#8212;',
+	"\xD2" => '&#8220;',
+	"\xD3" => '&#8221;',
+	"\xD4" => '&#8216;',
+	"\xD5" => '&#8217;',
+	"\xD6" => '&#247;',
+	"\xD7" => '&#8222;',
+	"\xD8" => '&#1038;',
+	"\xD9" => '&#1118;',
+	"\xDA" => '&#1039;',
+	"\xDB" => '&#1119;',
+	"\xDC" => '&#8470;',
+	"\xDD" => '&#1025;',
+	"\xDE" => '&#1105;',
+	"\xDF" => '&#1103;',
+	"\xE0" => '&#1072;',
+	"\xE1" => '&#1073;',
+	"\xE2" => '&#1074;',
+	"\xE3" => '&#1075;',
+	"\xE4" => '&#1076;',
+	"\xE5" => '&#1077;',
+	"\xE6" => '&#1078;',
+	"\xE7" => '&#1079;',
+	"\xE8" => '&#1080;',
+	"\xE9" => '&#1081;',
+	"\xEA" => '&#1082;',
+	"\xEB" => '&#1083;',
+	"\xEC" => '&#1084;',
+	"\xED" => '&#1085;',
+	"\xEE" => '&#1086;',
+	"\xEF" => '&#1087;',
+	"\xF0" => '&#1088;',
+	"\xF1" => '&#1089;',
+	"\xF2" => '&#1090;',
+	"\xF3" => '&#1091;',
+	"\xF4" => '&#1092;',
+	"\xF5" => '&#1093;',
+	"\xF6" => '&#1094;',
+	"\xF7" => '&#1095;',
+	"\xF8" => '&#1096;',
+	"\xF9" => '&#1097;',
+	"\xFA" => '&#1098;',
+	"\xFB" => '&#1099;',
+	"\xFC" => '&#1100;',
+	"\xFD" => '&#1101;',
+	"\xFE" => '&#1102;',
+	"\xFF" => '&#164;'
+    );
+
+    $string = str_replace(array_keys($cp10007), array_values($cp10007), $string);
+
+    return $string;
+}
+?>

+ 169 - 0
functions/decode/cp10017.php

@@ -0,0 +1,169 @@
+<?php
+/*
+ * decode/cp10017.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp10017 (MacUkrainian) decoding function that 
+ * is needed to read cp10017 encoded mails in non-cp10017 locale.
+ * 
+ * Apple states [2] that x-mac-ukrainian differs from x-mac-cyrillic [1] 
+ * only in two places. According to [3] these symbols are:
+ *  0x92 - U+1168 - CYRILLIC CAPITAL LETTER GHE WITH UPTURN
+ *  0xD6 - U+1169 - CYRILLIC SMALL LETTER GHE WITH UPTURN
+ *
+ * References:
+ * 1. ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/CYRILLIC.TXT
+ * 2. http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html
+ * 3. http://shlimazl.nm.ru/rus/cptable.htm (page in Russian)
+ */
+
+function charset_decode_cp10017 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'x-mac-ukrainian')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp10017 = array(
+	"\x80" => '&#1040;',
+	"\x81" => '&#1041;',
+	"\x82" => '&#1042;',
+	"\x83" => '&#1043;',
+	"\x84" => '&#1044;',
+	"\x85" => '&#1045;',
+	"\x86" => '&#1046;',
+	"\x87" => '&#1047;',
+	"\x88" => '&#1048;',
+	"\x89" => '&#1049;',
+	"\x8A" => '&#1050;',
+	"\x8B" => '&#1051;',
+	"\x8C" => '&#1052;',
+	"\x8D" => '&#1053;',
+	"\x8E" => '&#1054;',
+	"\x8F" => '&#1055;',
+	"\x90" => '&#1056;',
+	"\x91" => '&#1057;',
+	"\x92" => '&#1168;',
+	"\x93" => '&#1059;',
+	"\x94" => '&#1060;',
+	"\x95" => '&#1061;',
+	"\x96" => '&#1062;',
+	"\x97" => '&#1063;',
+	"\x98" => '&#1064;',
+	"\x99" => '&#1065;',
+	"\x9A" => '&#1066;',
+	"\x9B" => '&#1067;',
+	"\x9C" => '&#1068;',
+	"\x9D" => '&#1069;',
+	"\x9E" => '&#1070;',
+	"\x9F" => '&#1071;',
+	"\xA0" => '&#8224;',
+	"\xA1" => '&#176;',
+	"\xA2" => '&#162;',
+	"\xA3" => '&#163;',
+	"\xA4" => '&#167;',
+	"\xA5" => '&#8226;',
+	"\xA6" => '&#182;',
+	"\xA7" => '&#1030;',
+	"\xA8" => '&#174;',
+	"\xA9" => '&#169;',
+	"\xAA" => '&#8482;',
+	"\xAB" => '&#1026;',
+	"\xAC" => '&#1106;',
+	"\xAD" => '&#8800;',
+	"\xAE" => '&#1027;',
+	"\xAF" => '&#1107;',
+	"\xB0" => '&#8734;',
+	"\xB1" => '&#177;',
+	"\xB2" => '&#8804;',
+	"\xB3" => '&#8805;',
+	"\xB4" => '&#1110;',
+	"\xB5" => '&#181;',
+	"\xB6" => '&#8706;',
+	"\xB7" => '&#1032;',
+	"\xB8" => '&#1028;',
+	"\xB9" => '&#1108;',
+	"\xBA" => '&#1031;',
+	"\xBB" => '&#1111;',
+	"\xBC" => '&#1033;',
+	"\xBD" => '&#1113;',
+	"\xBE" => '&#1034;',
+	"\xBF" => '&#1114;',
+	"\xC0" => '&#1112;',
+	"\xC1" => '&#1029;',
+	"\xC2" => '&#172;',
+	"\xC3" => '&#8730;',
+	"\xC4" => '&#402;',
+	"\xC5" => '&#8776;',
+	"\xC6" => '&#8710;',
+	"\xC7" => '&#171;',
+	"\xC8" => '&#187;',
+	"\xC9" => '&#8230;',
+	"\xCA" => '&#160;',
+	"\xCB" => '&#1035;',
+	"\xCC" => '&#1115;',
+	"\xCD" => '&#1036;',
+	"\xCE" => '&#1116;',
+	"\xCF" => '&#1109;',
+	"\xD0" => '&#8211;',
+	"\xD1" => '&#8212;',
+	"\xD2" => '&#8220;',
+	"\xD3" => '&#8221;',
+	"\xD4" => '&#8216;',
+	"\xD5" => '&#8217;',
+	"\xD6" => '&#1169;',
+	"\xD7" => '&#8222;',
+	"\xD8" => '&#1038;',
+	"\xD9" => '&#1118;',
+	"\xDA" => '&#1039;',
+	"\xDB" => '&#1119;',
+	"\xDC" => '&#8470;',
+	"\xDD" => '&#1025;',
+	"\xDE" => '&#1105;',
+	"\xDF" => '&#1103;',
+	"\xE0" => '&#1072;',
+	"\xE1" => '&#1073;',
+	"\xE2" => '&#1074;',
+	"\xE3" => '&#1075;',
+	"\xE4" => '&#1076;',
+	"\xE5" => '&#1077;',
+	"\xE6" => '&#1078;',
+	"\xE7" => '&#1079;',
+	"\xE8" => '&#1080;',
+	"\xE9" => '&#1081;',
+	"\xEA" => '&#1082;',
+	"\xEB" => '&#1083;',
+	"\xEC" => '&#1084;',
+	"\xED" => '&#1085;',
+	"\xEE" => '&#1086;',
+	"\xEF" => '&#1087;',
+	"\xF0" => '&#1088;',
+	"\xF1" => '&#1089;',
+	"\xF2" => '&#1090;',
+	"\xF3" => '&#1091;',
+	"\xF4" => '&#1092;',
+	"\xF5" => '&#1093;',
+	"\xF6" => '&#1094;',
+	"\xF7" => '&#1095;',
+	"\xF8" => '&#1096;',
+	"\xF9" => '&#1097;',
+	"\xFA" => '&#1098;',
+	"\xFB" => '&#1099;',
+	"\xFC" => '&#1100;',
+	"\xFD" => '&#1101;',
+	"\xFE" => '&#1102;',
+	"\xFF" => '&#164;'
+    );
+
+    $string = str_replace(array_keys($cp10017), array_values($cp10017), $string);
+
+    return $string;
+}
+?>

+ 170 - 0
functions/decode/cp10029.php

@@ -0,0 +1,170 @@
+<?php
+/*
+ * decode/cp10029.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp10029 (MacLatin2) decoding function that 
+ * is needed to read cp10029 encoded mails in non-cp10029 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/LATIN2.TXT
+ *
+ *  Name:     cp10029_MacLatin2 to Unicode table
+ *  Unicode version: 2.0
+ *  Table version: 2.00
+ *  Table format:  Format A
+ *  Date:          04/24/96
+ *  Authors:       Lori Brownell <loribr@microsoft.com>
+ *                 K.D. Chang    <a-kchang@microsoft.com>
+ */
+
+function charset_decode_cp10029 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'x-mac-centraleurroman')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp10029 = array(
+	"\0x80" => '&#196;',
+	"\0x81" => '&#256;',
+	"\0x82" => '&#257;',
+	"\0x83" => '&#201;',
+	"\0x84" => '&#260;',
+	"\0x85" => '&#214;',
+	"\0x86" => '&#220;',
+	"\0x87" => '&#225;',
+	"\0x88" => '&#261;',
+	"\0x89" => '&#268;',
+	"\0x8A" => '&#228;',
+	"\0x8B" => '&#269;',
+	"\0x8C" => '&#262;',
+	"\0x8D" => '&#263;',
+	"\0x8E" => '&#233;',
+	"\0x8F" => '&#377;',
+	"\0x90" => '&#378;',
+	"\0x91" => '&#270;',
+	"\0x92" => '&#237;',
+	"\0x93" => '&#271;',
+	"\0x94" => '&#274;',
+	"\0x95" => '&#275;',
+	"\0x96" => '&#278;',
+	"\0x97" => '&#243;',
+	"\0x98" => '&#279;',
+	"\0x99" => '&#244;',
+	"\0x9A" => '&#246;',
+	"\0x9B" => '&#245;',
+	"\0x9C" => '&#250;',
+	"\0x9D" => '&#282;',
+	"\0x9E" => '&#283;',
+	"\0x9F" => '&#252;',
+	"\0xA0" => '&#8224;',
+	"\0xA1" => '&#176;',
+	"\0xA2" => '&#280;',
+	"\0xA3" => '&#163;',
+	"\0xA4" => '&#167;',
+	"\0xA5" => '&#8226;',
+	"\0xA6" => '&#182;',
+	"\0xA7" => '&#223;',
+	"\0xA8" => '&#174;',
+	"\0xA9" => '&#169;',
+	"\0xAA" => '&#8482;',
+	"\0xAB" => '&#281;',
+	"\0xAC" => '&#168;',
+	"\0xAD" => '&#8800;',
+	"\0xAE" => '&#291;',
+	"\0xAF" => '&#302;',
+	"\0xB0" => '&#303;',
+	"\0xB1" => '&#298;',
+	"\0xB2" => '&#8804;',
+	"\0xB3" => '&#8805;',
+	"\0xB4" => '&#299;',
+	"\0xB5" => '&#310;',
+	"\0xB6" => '&#8706;',
+	"\0xB7" => '&#8721;',
+	"\0xB8" => '&#322;',
+	"\0xB9" => '&#315;',
+	"\0xBA" => '&#316;',
+	"\0xBB" => '&#317;',
+	"\0xBC" => '&#318;',
+	"\0xBD" => '&#313;',
+	"\0xBE" => '&#314;',
+	"\0xBF" => '&#325;',
+	"\0xC0" => '&#326;',
+	"\0xC1" => '&#323;',
+	"\0xC2" => '&#172;',
+	"\0xC3" => '&#8730;',
+	"\0xC4" => '&#324;',
+	"\0xC5" => '&#327;',
+	"\0xC6" => '&#8710;',
+	"\0xC7" => '&#171;',
+	"\0xC8" => '&#187;',
+	"\0xC9" => '&#8230;',
+	"\0xCA" => '&#160;',
+	"\0xCB" => '&#328;',
+	"\0xCC" => '&#336;',
+	"\0xCD" => '&#213;',
+	"\0xCE" => '&#337;',
+	"\0xCF" => '&#332;',
+	"\0xD0" => '&#8211;',
+	"\0xD1" => '&#8212;',
+	"\0xD2" => '&#8220;',
+	"\0xD3" => '&#8221;',
+	"\0xD4" => '&#8216;',
+	"\0xD5" => '&#8217;',
+	"\0xD6" => '&#247;',
+	"\0xD7" => '&#9674;',
+	"\0xD8" => '&#333;',
+	"\0xD9" => '&#340;',
+	"\0xDA" => '&#341;',
+	"\0xDB" => '&#344;',
+	"\0xDC" => '&#8249;',
+	"\0xDD" => '&#8250;',
+	"\0xDE" => '&#345;',
+	"\0xDF" => '&#342;',
+	"\0xE0" => '&#343;',
+	"\0xE1" => '&#352;',
+	"\0xE2" => '&#8218;',
+	"\0xE3" => '&#8222;',
+	"\0xE4" => '&#353;',
+	"\0xE5" => '&#346;',
+	"\0xE6" => '&#347;',
+	"\0xE7" => '&#193;',
+	"\0xE8" => '&#356;',
+	"\0xE9" => '&#357;',
+	"\0xEA" => '&#205;',
+	"\0xEB" => '&#381;',
+	"\0xEC" => '&#382;',
+	"\0xED" => '&#362;',
+	"\0xEE" => '&#211;',
+	"\0xEF" => '&#212;',
+	"\0xF0" => '&#363;',
+	"\0xF1" => '&#366;',
+	"\0xF2" => '&#218;',
+	"\0xF3" => '&#367;',
+	"\0xF4" => '&#368;',
+	"\0xF5" => '&#369;',
+	"\0xF6" => '&#370;',
+	"\0xF7" => '&#371;',
+	"\0xF8" => '&#221;',
+	"\0xF9" => '&#253;',
+	"\0xFA" => '&#311;',
+	"\0xFB" => '&#379;',
+	"\0xFC" => '&#321;',
+	"\0xFD" => '&#380;',
+	"\0xFE" => '&#290;',
+	"\0xFF" => '&#711;'
+   );
+
+    $string = str_replace(array_keys($cp10029), array_values($cp10029), $string);
+
+    return $string;
+}
+?>

+ 170 - 0
functions/decode/cp10079.php

@@ -0,0 +1,170 @@
+<?php
+/*
+ * decode/cp10079.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp10079 (MacIcelandic) decoding function that 
+ * is needed to read cp10079 encoded mails in non-cp10079 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/ICELAND.TXT
+ *
+ *  Name:     cp10079_MacIcelandic to Unicode table
+ *  Unicode version: 2.0
+ *  Table version: 2.00
+ *  Table format:  Format A
+ *  Date:          04/24/96
+ *  Authors:       Lori Brownell <loribr@microsoft.com>
+ *                 K.D. Chang    <a-kchang@microsoft.com>
+ */
+
+function charset_decode_cp10079 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'x-mac-icelandic')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp10079 = array(
+	"\0x80" => '&#196;',
+	"\0x81" => '&#197;',
+	"\0x82" => '&#199;',
+	"\0x83" => '&#201;',
+	"\0x84" => '&#209;',
+	"\0x85" => '&#214;',
+	"\0x86" => '&#220;',
+	"\0x87" => '&#225;',
+	"\0x88" => '&#224;',
+	"\0x89" => '&#226;',
+	"\0x8A" => '&#228;',
+	"\0x8B" => '&#227;',
+	"\0x8C" => '&#229;',
+	"\0x8D" => '&#231;',
+	"\0x8E" => '&#233;',
+	"\0x8F" => '&#232;',
+	"\0x90" => '&#234;',
+	"\0x91" => '&#235;',
+	"\0x92" => '&#237;',
+	"\0x93" => '&#236;',
+	"\0x94" => '&#238;',
+	"\0x95" => '&#239;',
+	"\0x96" => '&#241;',
+	"\0x97" => '&#243;',
+	"\0x98" => '&#242;',
+	"\0x99" => '&#244;',
+	"\0x9A" => '&#246;',
+	"\0x9B" => '&#245;',
+	"\0x9C" => '&#250;',
+	"\0x9D" => '&#249;',
+	"\0x9E" => '&#251;',
+	"\0x9F" => '&#252;',
+	"\0xA0" => '&#221;',
+	"\0xA1" => '&#176;',
+	"\0xA2" => '&#162;',
+	"\0xA3" => '&#163;',
+	"\0xA4" => '&#167;',
+	"\0xA5" => '&#8226;',
+	"\0xA6" => '&#182;',
+	"\0xA7" => '&#223;',
+	"\0xA8" => '&#174;',
+	"\0xA9" => '&#169;',
+	"\0xAA" => '&#8482;',
+	"\0xAB" => '&#180;',
+	"\0xAC" => '&#168;',
+	"\0xAD" => '&#8800;',
+	"\0xAE" => '&#198;',
+	"\0xAF" => '&#216;',
+	"\0xB0" => '&#8734;',
+	"\0xB1" => '&#177;',
+	"\0xB2" => '&#8804;',
+	"\0xB3" => '&#8805;',
+	"\0xB4" => '&#165;',
+	"\0xB5" => '&#181;',
+	"\0xB6" => '&#8706;',
+	"\0xB7" => '&#8721;',
+	"\0xB8" => '&#8719;',
+	"\0xB9" => '&#960;',
+	"\0xBA" => '&#8747;',
+	"\0xBB" => '&#170;',
+	"\0xBC" => '&#186;',
+	"\0xBD" => '&#8486;',
+	"\0xBE" => '&#230;',
+	"\0xBF" => '&#248;',
+	"\0xC0" => '&#191;',
+	"\0xC1" => '&#161;',
+	"\0xC2" => '&#172;',
+	"\0xC3" => '&#8730;',
+	"\0xC4" => '&#402;',
+	"\0xC5" => '&#8776;',
+	"\0xC6" => '&#8710;',
+	"\0xC7" => '&#171;',
+	"\0xC8" => '&#187;',
+	"\0xC9" => '&#8230;',
+	"\0xCA" => '&#160;',
+	"\0xCB" => '&#192;',
+	"\0xCC" => '&#195;',
+	"\0xCD" => '&#213;',
+	"\0xCE" => '&#338;',
+	"\0xCF" => '&#339;',
+	"\0xD0" => '&#8211;',
+	"\0xD1" => '&#8212;',
+	"\0xD2" => '&#8220;',
+	"\0xD3" => '&#8221;',
+	"\0xD4" => '&#8216;',
+	"\0xD5" => '&#8217;',
+	"\0xD6" => '&#247;',
+	"\0xD7" => '&#9674;',
+	"\0xD8" => '&#255;',
+	"\0xD9" => '&#376;',
+	"\0xDA" => '&#8260;',
+	"\0xDB" => '&#164;',
+	"\0xDC" => '&#208;',
+	"\0xDD" => '&#240;',
+	"\0xDE" => '&#222;',
+	"\0xDF" => '&#254;',
+	"\0xE0" => '&#253;',
+	"\0xE1" => '&#183;',
+	"\0xE2" => '&#8218;',
+	"\0xE3" => '&#8222;',
+	"\0xE4" => '&#8240;',
+	"\0xE5" => '&#194;',
+	"\0xE6" => '&#202;',
+	"\0xE7" => '&#193;',
+	"\0xE8" => '&#203;',
+	"\0xE9" => '&#200;',
+	"\0xEA" => '&#205;',
+	"\0xEB" => '&#206;',
+	"\0xEC" => '&#207;',
+	"\0xED" => '&#204;',
+	"\0xEE" => '&#211;',
+	"\0xEF" => '&#212;',
+	"\0xF0" => '&#65535;',
+	"\0xF1" => '&#210;',
+	"\0xF2" => '&#218;',
+	"\0xF3" => '&#219;',
+	"\0xF4" => '&#217;',
+	"\0xF5" => '&#305;',
+	"\0xF6" => '&#710;',
+	"\0xF7" => '&#732;',
+	"\0xF8" => '&#175;',
+	"\0xF9" => '&#728;',
+	"\0xFA" => '&#729;',
+	"\0xFB" => '&#730;',
+	"\0xFC" => '&#184;',
+	"\0xFD" => '&#733;',
+	"\0xFE" => '&#731;',
+	"\0xFF" => '&#711;'
+   );
+
+    $string = str_replace(array_keys($cp10079), array_values($cp10079), $string);
+
+    return $string;
+}
+?>

+ 170 - 0
functions/decode/cp10081.php

@@ -0,0 +1,170 @@
+<?php
+/*
+ * decode/cp10081.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp10081 (MacTurkish) decoding function that 
+ * is needed to read cp10081 encoded mails in non-cp10081 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/TURKISH.TXT
+ *
+ *  Name:     cp10081_MacTurkish to Unicode table
+ *  Unicode version: 2.0
+ *  Table version: 2.00
+ *  Table format:  Format A
+ *  Date:          04/24/96
+ *  Authors:       Lori Brownell <loribr@microsoft.com>
+ *                 K.D. Chang    <a-kchang@microsoft.com>
+ */
+
+function charset_decode_cp10081 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'x-mac-turkish')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp10081 = array(
+	"\0x80" => '&#196;',
+	"\0x81" => '&#197;',
+	"\0x82" => '&#199;',
+	"\0x83" => '&#201;',
+	"\0x84" => '&#209;',
+	"\0x85" => '&#214;',
+	"\0x86" => '&#220;',
+	"\0x87" => '&#225;',
+	"\0x88" => '&#224;',
+	"\0x89" => '&#226;',
+	"\0x8A" => '&#228;',
+	"\0x8B" => '&#227;',
+	"\0x8C" => '&#229;',
+	"\0x8D" => '&#231;',
+	"\0x8E" => '&#233;',
+	"\0x8F" => '&#232;',
+	"\0x90" => '&#234;',
+	"\0x91" => '&#235;',
+	"\0x92" => '&#237;',
+	"\0x93" => '&#236;',
+	"\0x94" => '&#238;',
+	"\0x95" => '&#239;',
+	"\0x96" => '&#241;',
+	"\0x97" => '&#243;',
+	"\0x98" => '&#242;',
+	"\0x99" => '&#244;',
+	"\0x9A" => '&#246;',
+	"\0x9B" => '&#245;',
+	"\0x9C" => '&#250;',
+	"\0x9D" => '&#249;',
+	"\0x9E" => '&#251;',
+	"\0x9F" => '&#252;',
+	"\0xA0" => '&#8224;',
+	"\0xA1" => '&#176;',
+	"\0xA2" => '&#162;',
+	"\0xA3" => '&#163;',
+	"\0xA4" => '&#167;',
+	"\0xA5" => '&#8226;',
+	"\0xA6" => '&#182;',
+	"\0xA7" => '&#223;',
+	"\0xA8" => '&#174;',
+	"\0xA9" => '&#169;',
+	"\0xAA" => '&#8482;',
+	"\0xAB" => '&#180;',
+	"\0xAC" => '&#168;',
+	"\0xAD" => '&#8800;',
+	"\0xAE" => '&#198;',
+	"\0xAF" => '&#216;',
+	"\0xB0" => '&#8734;',
+	"\0xB1" => '&#177;',
+	"\0xB2" => '&#8804;',
+	"\0xB3" => '&#8805;',
+	"\0xB4" => '&#165;',
+	"\0xB5" => '&#181;',
+	"\0xB6" => '&#8706;',
+	"\0xB7" => '&#8721;',
+	"\0xB8" => '&#8719;',
+	"\0xB9" => '&#960;',
+	"\0xBA" => '&#8747;',
+	"\0xBB" => '&#170;',
+	"\0xBC" => '&#186;',
+	"\0xBD" => '&#8486;',
+	"\0xBE" => '&#230;',
+	"\0xBF" => '&#248;',
+	"\0xC0" => '&#191;',
+	"\0xC1" => '&#161;',
+	"\0xC2" => '&#172;',
+	"\0xC3" => '&#8730;',
+	"\0xC4" => '&#402;',
+	"\0xC5" => '&#8776;',
+	"\0xC6" => '&#8710;',
+	"\0xC7" => '&#171;',
+	"\0xC8" => '&#187;',
+	"\0xC9" => '&#8230;',
+	"\0xCA" => '&#160;',
+	"\0xCB" => '&#192;',
+	"\0xCC" => '&#195;',
+	"\0xCD" => '&#213;',
+	"\0xCE" => '&#338;',
+	"\0xCF" => '&#339;',
+	"\0xD0" => '&#8211;',
+	"\0xD1" => '&#8212;',
+	"\0xD2" => '&#8220;',
+	"\0xD3" => '&#8221;',
+	"\0xD4" => '&#8216;',
+	"\0xD5" => '&#8217;',
+	"\0xD6" => '&#247;',
+	"\0xD7" => '&#9674;',
+	"\0xD8" => '&#255;',
+	"\0xD9" => '&#376;',
+	"\0xDA" => '&#286;',
+	"\0xDB" => '&#287;',
+	"\0xDC" => '&#304;',
+	"\0xDD" => '&#305;',
+	"\0xDE" => '&#350;',
+	"\0xDF" => '&#351;',
+	"\0xE0" => '&#8225;',
+	"\0xE1" => '&#183;',
+	"\0xE2" => '&#8218;',
+	"\0xE3" => '&#8222;',
+	"\0xE4" => '&#8240;',
+	"\0xE5" => '&#194;',
+	"\0xE6" => '&#202;',
+	"\0xE7" => '&#193;',
+	"\0xE8" => '&#203;',
+	"\0xE9" => '&#200;',
+	"\0xEA" => '&#205;',
+	"\0xEB" => '&#206;',
+	"\0xEC" => '&#207;',
+	"\0xED" => '&#204;',
+	"\0xEE" => '&#211;',
+	"\0xEF" => '&#212;',
+	"\0xF0" => '&#65535;',
+	"\0xF1" => '&#210;',
+	"\0xF2" => '&#218;',
+	"\0xF3" => '&#219;',
+	"\0xF4" => '&#217;',
+	"\0xF5" => '&#65535;',
+	"\0xF6" => '&#710;',
+	"\0xF7" => '&#732;',
+	"\0xF8" => '&#175;',
+	"\0xF9" => '&#728;',
+	"\0xFA" => '&#729;',
+	"\0xFB" => '&#730;',
+	"\0xFC" => '&#184;',
+	"\0xFD" => '&#733;',
+	"\0xFE" => '&#731;',
+	"\0xFF" => '&#711;'
+   );
+
+    $string = str_replace(array_keys($cp10081), array_values($cp10081), $string);
+
+    return $string;
+}
+?>

+ 170 - 0
functions/decode/cp855.php

@@ -0,0 +1,170 @@
+<?php
+/*
+ * decode/cp855.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp855 decoding function that is needed to read
+ * cp855 encoded mails in non-cp855 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP855.TXT
+ *   Name:     cp855_DOSCyrillic to Unicode table
+ *   Unicode version: 2.0
+ *   Table version: 2.00
+ *   Table format:  Format A
+ *   Date:          04/24/96
+ *   Authors:       Lori Brownell <loribr@microsoft.com>
+ *                  K.D. Chang    <a-kchang@microsoft.com>
+ */
+
+function charset_decode_cp855 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'ibm855')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp855 = array(
+	"\x80" => '&#1106;',
+	"\x81" => '&#1026;',
+	"\x82" => '&#1107;',
+	"\x83" => '&#1027;',
+	"\x84" => '&#1105;',
+	"\x85" => '&#1025;',
+	"\x86" => '&#1108;',
+	"\x87" => '&#1028;',
+	"\x88" => '&#1109;',
+	"\x89" => '&#1029;',
+	"\x8a" => '&#1110;',
+	"\x8b" => '&#1030;',
+	"\x8c" => '&#1111;',
+	"\x8d" => '&#1031;',
+	"\x8e" => '&#1112;',
+	"\x8f" => '&#1032;',
+	"\x90" => '&#1113;',
+	"\x91" => '&#1033;',
+	"\x92" => '&#1114;',
+	"\x93" => '&#1034;',
+	"\x94" => '&#1115;',
+	"\x95" => '&#1035;',
+	"\x96" => '&#1116;',
+	"\x97" => '&#1036;',
+	"\x98" => '&#1118;',
+	"\x99" => '&#1038;',
+	"\x9a" => '&#1119;',
+	"\x9b" => '&#1039;',
+	"\x9c" => '&#1102;',
+	"\x9d" => '&#1070;',
+	"\x9e" => '&#1098;',
+	"\x9f" => '&#1066;',
+	"\xa0" => '&#1072;',
+	"\xa1" => '&#1040;',
+	"\xa2" => '&#1073;',
+	"\xa3" => '&#1041;',
+	"\xa4" => '&#1094;',
+	"\xa5" => '&#1062;',
+	"\xa6" => '&#1076;',
+	"\xa7" => '&#1044;',
+	"\xa8" => '&#1077;',
+	"\xa9" => '&#1045;',
+	"\xaa" => '&#1092;',
+	"\xab" => '&#1060;',
+	"\xac" => '&#1075;',
+	"\xad" => '&#1043;',
+	"\xae" => '&#171;',
+	"\xaf" => '&#187;',
+	"\xb0" => '&#9617;',
+	"\xb1" => '&#9618;',
+	"\xb2" => '&#9619;',
+	"\xb3" => '&#9474;',
+	"\xb4" => '&#9508;',
+	"\xb5" => '&#1093;',
+	"\xb6" => '&#1061;',
+	"\xb7" => '&#1080;',
+	"\xb8" => '&#1048;',
+	"\xb9" => '&#9571;',
+	"\xba" => '&#9553;',
+	"\xbb" => '&#9559;',
+	"\xbc" => '&#9565;',
+	"\xbd" => '&#1081;',
+	"\xbe" => '&#1049;',
+	"\xbf" => '&#9488;',
+	"\xc0" => '&#9492;',
+	"\xc1" => '&#9524;',
+	"\xc2" => '&#9516;',
+	"\xc3" => '&#9500;',
+	"\xc4" => '&#9472;',
+	"\xc5" => '&#9532;',
+	"\xc6" => '&#1082;',
+	"\xc7" => '&#1050;',
+	"\xc8" => '&#9562;',
+	"\xc9" => '&#9556;',
+	"\xca" => '&#9577;',
+	"\xcb" => '&#9574;',
+	"\xcc" => '&#9568;',
+	"\xcd" => '&#9552;',
+	"\xce" => '&#9580;',
+	"\xcf" => '&#164;',
+	"\xd0" => '&#1083;',
+	"\xd1" => '&#1051;',
+	"\xd2" => '&#1084;',
+	"\xd3" => '&#1052;',
+	"\xd4" => '&#1085;',
+	"\xd5" => '&#1053;',
+	"\xd6" => '&#1086;',
+	"\xd7" => '&#1054;',
+	"\xd8" => '&#1087;',
+	"\xd9" => '&#9496;',
+	"\xda" => '&#9484;',
+	"\xdb" => '&#9608;',
+	"\xdc" => '&#9604;',
+	"\xdd" => '&#1055;',
+	"\xde" => '&#1103;',
+	"\xdf" => '&#9600;',
+	"\xe0" => '&#1071;',
+	"\xe1" => '&#1088;',
+	"\xe2" => '&#1056;',
+	"\xe3" => '&#1089;',
+	"\xe4" => '&#1057;',
+	"\xe5" => '&#1090;',
+	"\xe6" => '&#1058;',
+	"\xe7" => '&#1091;',
+	"\xe8" => '&#1059;',
+	"\xe9" => '&#1078;',
+	"\xea" => '&#1046;',
+	"\xeb" => '&#1074;',
+	"\xec" => '&#1042;',
+	"\xed" => '&#1100;',
+	"\xee" => '&#1068;',
+	"\xef" => '&#8470;',
+	"\xf0" => '&#173;',
+	"\xf1" => '&#1099;',
+	"\xf2" => '&#1067;',
+	"\xf3" => '&#1079;',
+	"\xf4" => '&#1047;',
+	"\xf5" => '&#1096;',
+	"\xf6" => '&#1064;',
+	"\xf7" => '&#1101;',
+	"\xf8" => '&#1069;',
+	"\xf9" => '&#1097;',
+	"\xfa" => '&#1065;',
+	"\xfb" => '&#1095;',
+	"\xfc" => '&#1063;',
+	"\xfd" => '&#167;',
+	"\xfe" => '&#9632;',
+	"\xff" => '&#160;'
+    );
+
+    $string = str_replace(array_keys($cp855), array_values($cp855), $string);
+
+    return $string;
+}
+
+?>

+ 171 - 0
functions/decode/cp866.php

@@ -0,0 +1,171 @@
+<?php
+/*
+ * decode/cp866.php
+ * $Id$
+ *
+ * Copyright (c) 2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file contains cp866 decoding function that is needed to read
+ * cp866 encoded mails in non-cp866 locale.
+ * 
+ * Original data taken from:
+ *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/
+
+    Name:     cp866_DOSCyrillicRussian to Unicode table
+    Unicode version: 2.0
+    Table version: 2.00
+    Table format:  Format A
+    Date:          04/24/96
+    Authors:       Lori Brownell <loribr@microsoft.com>
+                   K.D. Chang    <a-kchang@microsoft.com>
+    The entries are in cp866_DOSCyrillicRussian order
+*/
+
+
+function charset_decode_cp866 ($string) {
+    global $default_charset;
+
+    if (strtolower($default_charset) == 'ibm866')
+        return $string;
+
+    /* Only do the slow convert if there are 8-bit characters */
+    /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
+    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+        return $string;
+
+    $cp866 = array(
+	"\x80" => '&#1040;',
+	"\x81" => '&#1041;',
+	"\x82" => '&#1042;',
+	"\x83" => '&#1043;',
+	"\x84" => '&#1044;',
+	"\x85" => '&#1045;',
+	"\x86" => '&#1046;',
+	"\x87" => '&#1047;',
+	"\x88" => '&#1048;',
+	"\x89" => '&#1049;',
+	"\x8a" => '&#1050;',
+	"\x8b" => '&#1051;',
+	"\x8c" => '&#1052;',
+	"\x8d" => '&#1053;',
+	"\x8e" => '&#1054;',
+	"\x8f" => '&#1055;',
+	"\x90" => '&#1056;',
+	"\x91" => '&#1057;',
+	"\x92" => '&#1058;',
+	"\x93" => '&#1059;',
+	"\x94" => '&#1060;',
+	"\x95" => '&#1061;',
+	"\x96" => '&#1062;',
+	"\x97" => '&#1063;',
+	"\x98" => '&#1064;',
+	"\x99" => '&#1065;',
+	"\x9a" => '&#1066;',
+	"\x9b" => '&#1067;',
+	"\x9c" => '&#1068;',
+	"\x9d" => '&#1069;',
+	"\x9e" => '&#1070;',
+	"\x9f" => '&#1071;',
+	"\xa0" => '&#1072;',
+	"\xa1" => '&#1073;',
+	"\xa2" => '&#1074;',
+	"\xa3" => '&#1075;',
+	"\xa4" => '&#1076;',
+	"\xa5" => '&#1077;',
+	"\xa6" => '&#1078;',
+	"\xa7" => '&#1079;',
+	"\xa8" => '&#1080;',
+	"\xa9" => '&#1081;',
+	"\xaa" => '&#1082;',
+	"\xab" => '&#1083;',
+	"\xac" => '&#1084;',
+	"\xad" => '&#1085;',
+	"\xae" => '&#1086;',
+	"\xaf" => '&#1087;',
+	"\xb0" => '&#9617;',
+	"\xb1" => '&#9618;',
+	"\xb2" => '&#9619;',
+	"\xb3" => '&#9474;',
+	"\xb4" => '&#9508;',
+	"\xb5" => '&#9569;',
+	"\xb6" => '&#9570;',
+	"\xb7" => '&#9558;',
+	"\xb8" => '&#9557;',
+	"\xb9" => '&#9571;',
+	"\xba" => '&#9553;',
+	"\xbb" => '&#9559;',
+	"\xbc" => '&#9565;',
+	"\xbd" => '&#9564;',
+	"\xbe" => '&#9563;',
+	"\xbf" => '&#9488;',
+	"\xc0" => '&#9492;',
+	"\xc1" => '&#9524;',
+	"\xc2" => '&#9516;',
+	"\xc3" => '&#9500;',
+	"\xc4" => '&#9472;',
+	"\xc5" => '&#9532;',
+	"\xc6" => '&#9566;',
+	"\xc7" => '&#9567;',
+	"\xc8" => '&#9562;',
+	"\xc9" => '&#9556;',
+	"\xca" => '&#9577;',
+	"\xcb" => '&#9574;',
+	"\xcc" => '&#9568;',
+	"\xcd" => '&#9552;',
+	"\xce" => '&#9580;',
+	"\xcf" => '&#9575;',
+	"\xd0" => '&#9576;',
+	"\xd1" => '&#9572;',
+	"\xd2" => '&#9573;',
+	"\xd3" => '&#9561;',
+	"\xd4" => '&#9560;',
+	"\xd5" => '&#9554;',
+	"\xd6" => '&#9555;',
+	"\xd7" => '&#9579;',
+	"\xd8" => '&#9578;',
+	"\xd9" => '&#9496;',
+	"\xda" => '&#9484;',
+	"\xdb" => '&#9608;',
+	"\xdc" => '&#9604;',
+	"\xdd" => '&#9612;',
+	"\xde" => '&#9616;',
+	"\xdf" => '&#9600;',
+	"\xe0" => '&#1088;',
+	"\xe1" => '&#1089;',
+	"\xe2" => '&#1090;',
+	"\xe3" => '&#1091;',
+	"\xe4" => '&#1092;',
+	"\xe5" => '&#1093;',
+	"\xe6" => '&#1094;',
+	"\xe7" => '&#1095;',
+	"\xe8" => '&#1096;',
+	"\xe9" => '&#1097;',
+	"\xea" => '&#1098;',
+	"\xeb" => '&#1099;',
+	"\xec" => '&#1100;',
+	"\xed" => '&#1101;',
+	"\xee" => '&#1102;',
+	"\xef" => '&#1103;',
+	"\xf0" => '&#1025;',
+	"\xf1" => '&#1105;',
+	"\xf2" => '&#1028;',
+	"\xf3" => '&#1108;',
+	"\xf4" => '&#1031;',
+	"\xf5" => '&#1111;',
+	"\xf6" => '&#1038;',
+	"\xf7" => '&#1118;',
+	"\xf8" => '&#176;',
+	"\xf9" => '&#8729;',
+	"\xfa" => '&#183;',
+	"\xfb" => '&#8730;',
+	"\xfc" => '&#8470;',
+	"\xfd" => '&#164;',
+	"\xfe" => '&#9632;',
+	"\xff" => '&#160;'
+    );
+
+    $string = str_replace(array_keys($cp866), array_values($cp866), $string);
+
+    return $string;
+}

+ 27 - 0
functions/i18n.php

@@ -160,6 +160,33 @@ function charset_decode ($charset, $string) {
     } else if ($charset == 'windows-1258') {
         include_once(SM_PATH . 'functions/decode/cp1258.php');
         $ret = charset_decode_cp1258 ($string);
+    } else if ($charset == 'x-mac-roman') {
+        include_once(SM_PATH . 'functions/decode/cp10000.php');
+        $ret = charset_decode_cp10000 ($string);
+    } else if ($charset == 'x-mac-greek') {
+        include_once(SM_PATH . 'functions/decode/cp10006.php');
+        $ret = charset_decode_cp10006 ($string);
+    } else if ($charset == 'x-mac-cyrillic') {
+        include_once(SM_PATH . 'functions/decode/cp10007.php');
+        $ret = charset_decode_cp10007 ($string);
+    } else if ($charset == 'x-mac-ukrainian') {
+        include_once(SM_PATH . 'functions/decode/cp10017.php');
+        $ret = charset_decode_cp10017 ($string);
+    } else if ($charset == 'x-mac-centraleurroman') {
+        include_once(SM_PATH . 'functions/decode/cp10029.php');
+        $ret = charset_decode_cp10029 ($string);
+    } else if ($charset == 'x-mac-icelandic') {
+        include_once(SM_PATH . 'functions/decode/cp10079.php');
+        $ret = charset_decode_cp10079 ($string);
+    } else if ($charset == 'x-mac-turkish') {
+        include_once(SM_PATH . 'functions/decode/cp10081.php');
+        $ret = charset_decode_cp10081 ($string);
+    } else if ($charset == 'ibm855') {
+        include_once(SM_PATH . 'functions/decode/cp855.php');
+        $ret = charset_decode_cp855 ($string);
+    } else if ($charset == 'ibm866') {
+        include_once(SM_PATH . 'functions/decode/cp866.php');
+        $ret = charset_decode_cp866 ($string);
     } else if ($charset == 'tis-620') {
         include_once(SM_PATH . 'functions/decode/tis620.php');
         $ret = charset_decode_tis620 ($string);