Explorar o código

using sq_is8bit function instead of ereg. Code reuse and fixes some problems
with mbstring overloading.

P.S. SquirrelMail login fails with
php_value mbstring.func_overload 2
php_value mbstring.internal_encoding utf-8

tokul %!s(int64=21) %!d(string=hai) anos
pai
achega
b59beee63b

+ 2 - 3
functions/decode/cp1250.php

@@ -34,9 +34,8 @@ function charset_decode_cp1250 ($string) {
     if (strtolower($default_charset) == 'windows-1250')
     if (strtolower($default_charset) == 'windows-1250')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1250'))
         return $string;
         return $string;
 
 
     $cp1250 = array(
     $cp1250 = array(

+ 2 - 3
functions/decode/cp1251.php

@@ -34,9 +34,8 @@ function charset_decode_cp1251 ($string) {
     if (strtolower($default_charset) == 'windows-1251')
     if (strtolower($default_charset) == 'windows-1251')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1251'))
         return $string;
         return $string;
 
 
     $cp1251 = array(
     $cp1251 = array(

+ 2 - 3
functions/decode/cp1252.php

@@ -35,9 +35,8 @@ function charset_decode_cp1252 ($string) {
     if (strtolower($default_charset) == 'windows-1252')
     if (strtolower($default_charset) == 'windows-1252')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1252'))
         return $string;
         return $string;
 
 
     $cp1252 = array(
     $cp1252 = array(

+ 2 - 3
functions/decode/cp1253.php

@@ -34,9 +34,8 @@ function charset_decode_cp1253 ($string) {
     if (strtolower($default_charset) == 'windows-1253')
     if (strtolower($default_charset) == 'windows-1253')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1253'))
         return $string;
         return $string;
 
 
     $cp1253 = array(
     $cp1253 = array(

+ 2 - 3
functions/decode/cp1254.php

@@ -34,9 +34,8 @@ function charset_decode_cp1254 ($string) {
     if (strtolower($default_charset) == 'windows-1254')
     if (strtolower($default_charset) == 'windows-1254')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1254'))
         return $string;
         return $string;
 
 
     $cp1254 = array(
     $cp1254 = array(

+ 2 - 3
functions/decode/cp1255.php

@@ -34,9 +34,8 @@ function charset_decode_cp1255 ($string) {
     if (strtolower($default_charset) == 'windows-1255')
     if (strtolower($default_charset) == 'windows-1255')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1255'))
         return $string;
         return $string;
 
 
     $cp1255 = array(
     $cp1255 = array(

+ 2 - 3
functions/decode/cp1256.php

@@ -34,9 +34,8 @@ function charset_decode_cp1256 ($string) {
     if (strtolower($default_charset) == 'windows-1256')
     if (strtolower($default_charset) == 'windows-1256')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1256'))
         return $string;
         return $string;
 
 
     $cp1256 = array(
     $cp1256 = array(

+ 2 - 3
functions/decode/cp1257.php

@@ -34,9 +34,8 @@ function charset_decode_cp1257 ($string) {
     if (strtolower($default_charset) == 'windows-1257')
     if (strtolower($default_charset) == 'windows-1257')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1257'))
         return $string;
         return $string;
 
 
     $cp1257 = array(
     $cp1257 = array(

+ 2 - 3
functions/decode/cp1258.php

@@ -34,9 +34,8 @@ function charset_decode_cp1258 ($string) {
     if (strtolower($default_charset) == 'windows-1258')
     if (strtolower($default_charset) == 'windows-1258')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'windows-1258'))
         return $string;
         return $string;
 
 
     $cp1258 = array(
     $cp1258 = array(

+ 2 - 3
functions/decode/cp855.php

@@ -34,9 +34,8 @@ function charset_decode_cp855 ($string) {
     if (strtolower($default_charset) == 'ibm855')
     if (strtolower($default_charset) == 'ibm855')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'ibm855'))
         return $string;
         return $string;
 
 
     $cp855 = array(
     $cp855 = array(

+ 2 - 3
functions/decode/cp866.php

@@ -36,9 +36,8 @@ function charset_decode_cp866 ($string) {
     if (strtolower($default_charset) == 'ibm866')
     if (strtolower($default_charset) == 'ibm866')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'ibm866'))
         return $string;
         return $string;
 
 
     $cp866 = array(
     $cp866 = array(

+ 3 - 4
functions/decode/iso_8859_1.php

@@ -24,9 +24,8 @@ function charset_decode_iso_8859_1 ($string) {
     if (strtolower($default_charset) == 'iso-8859-1')
     if (strtolower($default_charset) == 'iso-8859-1')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-1'))
         return $string;
         return $string;
 
 
     $string = preg_replace("/([\201-\237])/e","'&#' . ord('\\1') . ';'",$string);
     $string = preg_replace("/([\201-\237])/e","'&#' . ord('\\1') . ';'",$string);
@@ -38,4 +37,4 @@ function charset_decode_iso_8859_1 ($string) {
     return $string;
     return $string;
 }
 }
 
 
-?>
+?>

+ 112 - 113
functions/decode/iso_8859_10.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,108 +51,107 @@ function charset_decode_iso_8859_10 ($string) {
     if (strtolower($default_charset) == 'iso-8859-10')
     if (strtolower($default_charset) == 'iso-8859-10')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+     // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-10'))
         return $string;
         return $string;
 
 
     $iso8859_10 = array(
     $iso8859_10 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#260;',
-	"\xA2" => '&#274;',
-	"\xA3" => '&#290;',
-	"\xA4" => '&#298;',
-	"\xA5" => '&#296;',
-	"\xA6" => '&#310;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#315;',
-	"\xA9" => '&#272;',
-	"\xAA" => '&#352;',
-	"\xAB" => '&#358;',
-	"\xAC" => '&#381;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#362;',
-	"\xAF" => '&#330;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#261;',
-	"\xB2" => '&#275;',
-	"\xB3" => '&#291;',
-	"\xB4" => '&#299;',
-	"\xB5" => '&#297;',
-	"\xB6" => '&#311;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#316;',
-	"\xB9" => '&#273;',
-	"\xBA" => '&#353;',
-	"\xBB" => '&#359;',
-	"\xBC" => '&#382;',
-	"\xBD" => '&#8213;',
-	"\xBE" => '&#363;',
-	"\xBF" => '&#331;',
-	"\xC0" => '&#256;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC3" => '&#195;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#197;',
-	"\xC6" => '&#198;',
-	"\xC7" => '&#302;',
-	"\xC8" => '&#268;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#280;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#278;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#207;',
-	"\xD0" => '&#208;',
-	"\xD1" => '&#325;',
-	"\xD2" => '&#332;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#213;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#360;',
-	"\xD8" => '&#216;',
-	"\xD9" => '&#370;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#219;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#221;',
-	"\xDE" => '&#222;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#257;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE3" => '&#227;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#229;',
-	"\xE6" => '&#230;',
-	"\xE7" => '&#303;',
-	"\xE8" => '&#269;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#281;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#279;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#239;',
-	"\xF0" => '&#240;',
-	"\xF1" => '&#326;',
-	"\xF2" => '&#333;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#245;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#361;',
-	"\xF8" => '&#248;',
-	"\xF9" => '&#371;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#251;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#253;',
-	"\xFE" => '&#254;',
-	"\xFF" => '&#312;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#260;',
+        "\xA2" => '&#274;',
+        "\xA3" => '&#290;',
+        "\xA4" => '&#298;',
+        "\xA5" => '&#296;',
+        "\xA6" => '&#310;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#315;',
+        "\xA9" => '&#272;',
+        "\xAA" => '&#352;',
+        "\xAB" => '&#358;',
+        "\xAC" => '&#381;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#362;',
+        "\xAF" => '&#330;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#261;',
+        "\xB2" => '&#275;',
+        "\xB3" => '&#291;',
+        "\xB4" => '&#299;',
+        "\xB5" => '&#297;',
+        "\xB6" => '&#311;',
+        "\xB7" => '&#183;',
+        "\xB8" => '&#316;',
+        "\xB9" => '&#273;',
+        "\xBA" => '&#353;',
+        "\xBB" => '&#359;',
+        "\xBC" => '&#382;',
+        "\xBD" => '&#8213;',
+        "\xBE" => '&#363;',
+        "\xBF" => '&#331;',
+        "\xC0" => '&#256;',
+        "\xC1" => '&#193;',
+        "\xC2" => '&#194;',
+        "\xC3" => '&#195;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#197;',
+        "\xC6" => '&#198;',
+        "\xC7" => '&#302;',
+        "\xC8" => '&#268;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#280;',
+        "\xCB" => '&#203;',
+        "\xCC" => '&#278;',
+        "\xCD" => '&#205;',
+        "\xCE" => '&#206;',
+        "\xCF" => '&#207;',
+        "\xD0" => '&#208;',
+        "\xD1" => '&#325;',
+        "\xD2" => '&#332;',
+        "\xD3" => '&#211;',
+        "\xD4" => '&#212;',
+        "\xD5" => '&#213;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#360;',
+        "\xD8" => '&#216;',
+        "\xD9" => '&#370;',
+        "\xDA" => '&#218;',
+        "\xDB" => '&#219;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#221;',
+        "\xDE" => '&#222;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#257;',
+        "\xE1" => '&#225;',
+        "\xE2" => '&#226;',
+        "\xE3" => '&#227;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#229;',
+        "\xE6" => '&#230;',
+        "\xE7" => '&#303;',
+        "\xE8" => '&#269;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#281;',
+        "\xEB" => '&#235;',
+        "\xEC" => '&#279;',
+        "\xED" => '&#237;',
+        "\xEE" => '&#238;',
+        "\xEF" => '&#239;',
+        "\xF0" => '&#240;',
+        "\xF1" => '&#326;',
+        "\xF2" => '&#333;',
+        "\xF3" => '&#243;',
+        "\xF4" => '&#244;',
+        "\xF5" => '&#245;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#361;',
+        "\xF8" => '&#248;',
+        "\xF9" => '&#371;',
+        "\xFA" => '&#250;',
+        "\xFB" => '&#251;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#253;',
+        "\xFE" => '&#254;',
+        "\xFF" => '&#312;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_10), array_values($iso8859_10), $string);
     $string = str_replace(array_keys($iso8859_10), array_values($iso8859_10), $string);
@@ -160,4 +159,4 @@ function charset_decode_iso_8859_10 ($string) {
     return $string;
     return $string;
 }
 }
 
 
-?>
+?>

+ 2 - 3
functions/decode/iso_8859_11.php

@@ -51,9 +51,8 @@ function charset_decode_iso_8859_11 ($string) {
     if (strtolower($default_charset) == 'iso-8859-11')
     if (strtolower($default_charset) == 'iso-8859-11')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-11'))
         return $string;
         return $string;
 
 
     $iso8859_11 = array(
     $iso8859_11 = array(

+ 112 - 113
functions/decode/iso_8859_13.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,108 +51,107 @@ function charset_decode_iso_8859_13 ($string) {
     if (strtolower($default_charset) == 'iso-8859-13')
     if (strtolower($default_charset) == 'iso-8859-13')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+     // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-13'))
         return $string;
         return $string;
 
 
     $iso8859_13 = array(
     $iso8859_13 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#8221;',
-	"\xA2" => '&#162;',
-	"\xA3" => '&#163;',
-	"\xA4" => '&#164;',
-	"\xA5" => '&#8222;',
-	"\xA6" => '&#166;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#216;',
-	"\xA9" => '&#169;',
-	"\xAA" => '&#342;',
-	"\xAB" => '&#171;',
-	"\xAC" => '&#172;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#174;',
-	"\xAF" => '&#198;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#177;',
-	"\xB2" => '&#178;',
-	"\xB3" => '&#179;',
-	"\xB4" => '&#8220;',
-	"\xB5" => '&#181;',
-	"\xB6" => '&#182;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#248;',
-	"\xB9" => '&#185;',
-	"\xBA" => '&#343;',
-	"\xBB" => '&#187;',
-	"\xBC" => '&#188;',
-	"\xBD" => '&#189;',
-	"\xBE" => '&#190;',
-	"\xBF" => '&#230;',
-	"\xC0" => '&#260;',
-	"\xC1" => '&#302;',
-	"\xC2" => '&#256;',
-	"\xC3" => '&#262;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#197;',
-	"\xC6" => '&#280;',
-	"\xC7" => '&#274;',
-	"\xC8" => '&#268;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#377;',
-	"\xCB" => '&#278;',
-	"\xCC" => '&#290;',
-	"\xCD" => '&#310;',
-	"\xCE" => '&#298;',
-	"\xCF" => '&#315;',
-	"\xD0" => '&#352;',
-	"\xD1" => '&#323;',
-	"\xD2" => '&#325;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#332;',
-	"\xD5" => '&#213;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#215;',
-	"\xD8" => '&#370;',
-	"\xD9" => '&#321;',
-	"\xDA" => '&#346;',
-	"\xDB" => '&#362;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#379;',
-	"\xDE" => '&#381;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#261;',
-	"\xE1" => '&#303;',
-	"\xE2" => '&#257;',
-	"\xE3" => '&#263;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#229;',
-	"\xE6" => '&#281;',
-	"\xE7" => '&#275;',
-	"\xE8" => '&#269;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#378;',
-	"\xEB" => '&#279;',
-	"\xEC" => '&#291;',
-	"\xED" => '&#311;',
-	"\xEE" => '&#299;',
-	"\xEF" => '&#316;',
-	"\xF0" => '&#353;',
-	"\xF1" => '&#324;',
-	"\xF2" => '&#326;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#333;',
-	"\xF5" => '&#245;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#247;',
-	"\xF8" => '&#371;',
-	"\xF9" => '&#322;',
-	"\xFA" => '&#347;',
-	"\xFB" => '&#363;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#380;',
-	"\xFE" => '&#382;',
-	"\xFF" => '&#8217;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#8221;',
+        "\xA2" => '&#162;',
+        "\xA3" => '&#163;',
+        "\xA4" => '&#164;',
+        "\xA5" => '&#8222;',
+        "\xA6" => '&#166;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#216;',
+        "\xA9" => '&#169;',
+        "\xAA" => '&#342;',
+        "\xAB" => '&#171;',
+        "\xAC" => '&#172;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#174;',
+        "\xAF" => '&#198;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#177;',
+        "\xB2" => '&#178;',
+        "\xB3" => '&#179;',
+        "\xB4" => '&#8220;',
+        "\xB5" => '&#181;',
+        "\xB6" => '&#182;',
+        "\xB7" => '&#183;',
+        "\xB8" => '&#248;',
+        "\xB9" => '&#185;',
+        "\xBA" => '&#343;',
+        "\xBB" => '&#187;',
+        "\xBC" => '&#188;',
+        "\xBD" => '&#189;',
+        "\xBE" => '&#190;',
+        "\xBF" => '&#230;',
+        "\xC0" => '&#260;',
+        "\xC1" => '&#302;',
+        "\xC2" => '&#256;',
+        "\xC3" => '&#262;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#197;',
+        "\xC6" => '&#280;',
+        "\xC7" => '&#274;',
+        "\xC8" => '&#268;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#377;',
+        "\xCB" => '&#278;',
+        "\xCC" => '&#290;',
+        "\xCD" => '&#310;',
+        "\xCE" => '&#298;',
+        "\xCF" => '&#315;',
+        "\xD0" => '&#352;',
+        "\xD1" => '&#323;',
+        "\xD2" => '&#325;',
+        "\xD3" => '&#211;',
+        "\xD4" => '&#332;',
+        "\xD5" => '&#213;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#215;',
+        "\xD8" => '&#370;',
+        "\xD9" => '&#321;',
+        "\xDA" => '&#346;',
+        "\xDB" => '&#362;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#379;',
+        "\xDE" => '&#381;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#261;',
+        "\xE1" => '&#303;',
+        "\xE2" => '&#257;',
+        "\xE3" => '&#263;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#229;',
+        "\xE6" => '&#281;',
+        "\xE7" => '&#275;',
+        "\xE8" => '&#269;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#378;',
+        "\xEB" => '&#279;',
+        "\xEC" => '&#291;',
+        "\xED" => '&#311;',
+        "\xEE" => '&#299;',
+        "\xEF" => '&#316;',
+        "\xF0" => '&#353;',
+        "\xF1" => '&#324;',
+        "\xF2" => '&#326;',
+        "\xF3" => '&#243;',
+        "\xF4" => '&#333;',
+        "\xF5" => '&#245;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#247;',
+        "\xF8" => '&#371;',
+        "\xF9" => '&#322;',
+        "\xFA" => '&#347;',
+        "\xFB" => '&#363;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#380;',
+        "\xFE" => '&#382;',
+        "\xFF" => '&#8217;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_13), array_values($iso8859_13), $string);
     $string = str_replace(array_keys($iso8859_13), array_values($iso8859_13), $string);
@@ -160,4 +159,4 @@ function charset_decode_iso_8859_13 ($string) {
     return $string;
     return $string;
 }
 }
 
 
-?>
+?>

+ 113 - 115
functions/decode/iso_8859_14.php

@@ -17,24 +17,24 @@
  *   Table format:     Format A
  *   Table format:     Format A
  *   Date:             1999 July 27
  *   Date:             1999 July 27
  *   Authors:          Markus Kuhn <mkuhn@acm.org>
  *   Authors:          Markus Kuhn <mkuhn@acm.org>
- *		       Ken Whistler <kenw@sybase.com>
+ *                     Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -52,113 +52,111 @@ function charset_decode_iso_8859_14 ($string) {
     if (strtolower($default_charset) == 'iso-8859-14')
     if (strtolower($default_charset) == 'iso-8859-14')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-   /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-14'))
         return $string;
         return $string;
 
 
     $iso8859_14 = array(
     $iso8859_14 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#7682;',
-	"\xA2" => '&#7683;',
-	"\xA3" => '&#163;',
-	"\xA4" => '&#266;',
-	"\xA5" => '&#267;',
-	"\xA6" => '&#7690;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#7808;',
-	"\xA9" => '&#169;',
-	"\xAA" => '&#7810;',
-	"\xAB" => '&#7691;',
-	"\xAC" => '&#7922;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#174;',
-	"\xAF" => '&#376;',
-	"\xB0" => '&#7710;',
-	"\xB1" => '&#7711;',
-	"\xB2" => '&#288;',
-	"\xB3" => '&#289;',
-	"\xB4" => '&#7744;',
-	"\xB5" => '&#7745;',
-	"\xB6" => '&#182;',
-	"\xB7" => '&#7766;',
-	"\xB8" => '&#7809;',
-	"\xB9" => '&#7767;',
-	"\xBA" => '&#7811;',
-	"\xBB" => '&#7776;',
-	"\xBC" => '&#7923;',
-	"\xBD" => '&#7812;',
-	"\xBE" => '&#7813;',
-	"\xBF" => '&#7777;',
-	"\xC0" => '&#192;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC3" => '&#195;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#197;',
-	"\xC6" => '&#198;',
-	"\xC7" => '&#199;',
-	"\xC8" => '&#200;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#202;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#204;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#207;',
-	"\xD0" => '&#372;',
-	"\xD1" => '&#209;',
-	"\xD2" => '&#210;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#213;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#7786;',
-	"\xD8" => '&#216;',
-	"\xD9" => '&#217;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#219;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#221;',
-	"\xDE" => '&#374;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#224;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE3" => '&#227;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#229;',
-	"\xE6" => '&#230;',
-	"\xE7" => '&#231;',
-	"\xE8" => '&#232;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#234;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#236;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#239;',
-	"\xF0" => '&#373;',
-	"\xF1" => '&#241;',
-	"\xF2" => '&#242;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#245;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#7787;',
-	"\xF8" => '&#248;',
-	"\xF9" => '&#249;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#251;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#253;',
-	"\xFE" => '&#375;',
-	"\xFF" => '&#255;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#7682;',
+        "\xA2" => '&#7683;',
+        "\xA3" => '&#163;',
+        "\xA4" => '&#266;',
+        "\xA5" => '&#267;',
+        "\xA6" => '&#7690;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#7808;',
+        "\xA9" => '&#169;',
+        "\xAA" => '&#7810;',
+        "\xAB" => '&#7691;',
+        "\xAC" => '&#7922;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#174;',
+        "\xAF" => '&#376;',
+        "\xB0" => '&#7710;',
+        "\xB1" => '&#7711;',
+        "\xB2" => '&#288;',
+        "\xB3" => '&#289;',
+        "\xB4" => '&#7744;',
+        "\xB5" => '&#7745;',
+        "\xB6" => '&#182;',
+        "\xB7" => '&#7766;',
+        "\xB8" => '&#7809;',
+        "\xB9" => '&#7767;',
+        "\xBA" => '&#7811;',
+        "\xBB" => '&#7776;',
+        "\xBC" => '&#7923;',
+        "\xBD" => '&#7812;',
+        "\xBE" => '&#7813;',
+        "\xBF" => '&#7777;',
+        "\xC0" => '&#192;',
+        "\xC1" => '&#193;',
+        "\xC2" => '&#194;',
+        "\xC3" => '&#195;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#197;',
+        "\xC6" => '&#198;',
+        "\xC7" => '&#199;',
+        "\xC8" => '&#200;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#202;',
+        "\xCB" => '&#203;',
+        "\xCC" => '&#204;',
+        "\xCD" => '&#205;',
+        "\xCE" => '&#206;',
+        "\xCF" => '&#207;',
+        "\xD0" => '&#372;',
+        "\xD1" => '&#209;',
+        "\xD2" => '&#210;',
+        "\xD3" => '&#211;',
+        "\xD4" => '&#212;',
+        "\xD5" => '&#213;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#7786;',
+        "\xD8" => '&#216;',
+        "\xD9" => '&#217;',
+        "\xDA" => '&#218;',
+        "\xDB" => '&#219;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#221;',
+        "\xDE" => '&#374;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#224;',
+        "\xE1" => '&#225;',
+        "\xE2" => '&#226;',
+        "\xE3" => '&#227;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#229;',
+        "\xE6" => '&#230;',
+        "\xE7" => '&#231;',
+        "\xE8" => '&#232;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#234;',
+        "\xEB" => '&#235;',
+        "\xEC" => '&#236;',
+        "\xED" => '&#237;',
+        "\xEE" => '&#238;',
+        "\xEF" => '&#239;',
+        "\xF0" => '&#373;',
+        "\xF1" => '&#241;',
+        "\xF2" => '&#242;',
+        "\xF3" => '&#243;',
+        "\xF4" => '&#244;',
+        "\xF5" => '&#245;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#7787;',
+        "\xF8" => '&#248;',
+        "\xF9" => '&#249;',
+        "\xFA" => '&#250;',
+        "\xFB" => '&#251;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#253;',
+        "\xFE" => '&#375;',
+        "\xFF" => '&#255;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8869_14), array_values($iso8859_14), $string);
     $string = str_replace(array_keys($iso8869_14), array_values($iso8859_14), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 113 - 115
functions/decode/iso_8859_15.php

@@ -17,24 +17,24 @@
  *   Table format:     Format A
  *   Table format:     Format A
  *   Date:             1999 July 27
  *   Date:             1999 July 27
  *   Authors:          Markus Kuhn <mkuhn@acm.org>
  *   Authors:          Markus Kuhn <mkuhn@acm.org>
- *		       Ken Whistler <kenw@sybase.com>
+ *                     Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -52,113 +52,111 @@ function charset_decode_iso_8859_15 ($string) {
     if (strtolower($default_charset) == 'iso-8859-15')
     if (strtolower($default_charset) == 'iso-8859-15')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-15'))
         return $string;
         return $string;
 
 
     $iso8859_15 = array(
     $iso8859_15 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#161;',
-	"\xA2" => '&#162;',
-	"\xA3" => '&#163;',
-	"\xA4" => '&#8364;',
-	"\xA5" => '&#165;',
-	"\xA6" => '&#352;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#353;',
-	"\xA9" => '&#169;',
-	"\xAA" => '&#170;',
-	"\xAB" => '&#171;',
-	"\xAC" => '&#172;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#174;',
-	"\xAF" => '&#175;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#177;',
-	"\xB2" => '&#178;',
-	"\xB3" => '&#179;',
-	"\xB4" => '&#381;',
-	"\xB5" => '&#181;',
-	"\xB6" => '&#182;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#382;',
-	"\xB9" => '&#185;',
-	"\xBA" => '&#186;',
-	"\xBB" => '&#187;',
-	"\xBC" => '&#338;',
-	"\xBD" => '&#339;',
-	"\xBE" => '&#376;',
-	"\xBF" => '&#191;',
-	"\xC0" => '&#192;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC3" => '&#195;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#197;',
-	"\xC6" => '&#198;',
-	"\xC7" => '&#199;',
-	"\xC8" => '&#200;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#202;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#204;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#207;',
-	"\xD0" => '&#208;',
-	"\xD1" => '&#209;',
-	"\xD2" => '&#210;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#213;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#215;',
-	"\xD8" => '&#216;',
-	"\xD9" => '&#217;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#219;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#221;',
-	"\xDE" => '&#222;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#224;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE3" => '&#227;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#229;',
-	"\xE6" => '&#230;',
-	"\xE7" => '&#231;',
-	"\xE8" => '&#232;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#234;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#236;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#239;',
-	"\xF0" => '&#240;',
-	"\xF1" => '&#241;',
-	"\xF2" => '&#242;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#245;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#247;',
-	"\xF8" => '&#248;',
-	"\xF9" => '&#249;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#251;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#253;',
-	"\xFE" => '&#254;',
-	"\xFF" => '&#255;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#161;',
+        "\xA2" => '&#162;',
+        "\xA3" => '&#163;',
+        "\xA4" => '&#8364;',
+        "\xA5" => '&#165;',
+        "\xA6" => '&#352;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#353;',
+        "\xA9" => '&#169;',
+        "\xAA" => '&#170;',
+        "\xAB" => '&#171;',
+        "\xAC" => '&#172;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#174;',
+        "\xAF" => '&#175;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#177;',
+        "\xB2" => '&#178;',
+        "\xB3" => '&#179;',
+        "\xB4" => '&#381;',
+        "\xB5" => '&#181;',
+        "\xB6" => '&#182;',
+        "\xB7" => '&#183;',
+        "\xB8" => '&#382;',
+        "\xB9" => '&#185;',
+        "\xBA" => '&#186;',
+        "\xBB" => '&#187;',
+        "\xBC" => '&#338;',
+        "\xBD" => '&#339;',
+        "\xBE" => '&#376;',
+        "\xBF" => '&#191;',
+        "\xC0" => '&#192;',
+        "\xC1" => '&#193;',
+        "\xC2" => '&#194;',
+        "\xC3" => '&#195;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#197;',
+        "\xC6" => '&#198;',
+        "\xC7" => '&#199;',
+        "\xC8" => '&#200;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#202;',
+        "\xCB" => '&#203;',
+        "\xCC" => '&#204;',
+        "\xCD" => '&#205;',
+        "\xCE" => '&#206;',
+        "\xCF" => '&#207;',
+        "\xD0" => '&#208;',
+        "\xD1" => '&#209;',
+        "\xD2" => '&#210;',
+        "\xD3" => '&#211;',
+        "\xD4" => '&#212;',
+        "\xD5" => '&#213;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#215;',
+        "\xD8" => '&#216;',
+        "\xD9" => '&#217;',
+        "\xDA" => '&#218;',
+        "\xDB" => '&#219;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#221;',
+        "\xDE" => '&#222;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#224;',
+        "\xE1" => '&#225;',
+        "\xE2" => '&#226;',
+        "\xE3" => '&#227;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#229;',
+        "\xE6" => '&#230;',
+        "\xE7" => '&#231;',
+        "\xE8" => '&#232;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#234;',
+        "\xEB" => '&#235;',
+        "\xEC" => '&#236;',
+        "\xED" => '&#237;',
+        "\xEE" => '&#238;',
+        "\xEF" => '&#239;',
+        "\xF0" => '&#240;',
+        "\xF1" => '&#241;',
+        "\xF2" => '&#242;',
+        "\xF3" => '&#243;',
+        "\xF4" => '&#244;',
+        "\xF5" => '&#245;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#247;',
+        "\xF8" => '&#248;',
+        "\xF9" => '&#249;',
+        "\xFA" => '&#250;',
+        "\xFB" => '&#251;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#253;',
+        "\xFE" => '&#254;',
+        "\xFF" => '&#255;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string);
     $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 112 - 114
functions/decode/iso_8859_16.php

@@ -19,21 +19,21 @@
  *   Authors:          Markus Kuhn <mkuhn@acm.org>
  *   Authors:          Markus Kuhn <mkuhn@acm.org>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,113 +51,111 @@ function charset_decode_iso_8859_16 ($string) {
     if (strtolower($default_charset) == 'iso-8859-16')
     if (strtolower($default_charset) == 'iso-8859-16')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-16'))
         return $string;
         return $string;
 
 
     $iso8869_16 = array(
     $iso8869_16 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#260;',
-	"\xA2" => '&#261;',
-	"\xA3" => '&#321;',
-	"\xA4" => '&#8364;',
-	"\xA5" => '&#8222;',
-	"\xA6" => '&#352;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#353;',
-	"\xA9" => '&#169;',
-	"\xAA" => '&#536;',
-	"\xAB" => '&#171;',
-	"\xAC" => '&#377;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#378;',
-	"\xAF" => '&#379;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#177;',
-	"\xB2" => '&#268;',
-	"\xB3" => '&#322;',
-	"\xB4" => '&#381;',
-	"\xB5" => '&#8221;',
-	"\xB6" => '&#182;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#382;',
-	"\xB9" => '&#269;',
-	"\xBA" => '&#537;',
-	"\xBB" => '&#187;',
-	"\xBC" => '&#338;',
-	"\xBD" => '&#339;',
-	"\xBE" => '&#376;',
-	"\xBF" => '&#380;',
-	"\xC0" => '&#192;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC3" => '&#258;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#262;',
-	"\xC6" => '&#198;',
-	"\xC7" => '&#199;',
-	"\xC8" => '&#200;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#202;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#204;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#207;',
-	"\xD0" => '&#272;',
-	"\xD1" => '&#323;',
-	"\xD2" => '&#210;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#336;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#346;',
-	"\xD8" => '&#368;',
-	"\xD9" => '&#217;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#219;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#280;',
-	"\xDE" => '&#538;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#224;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE3" => '&#259;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#263;',
-	"\xE6" => '&#230;',
-	"\xE7" => '&#231;',
-	"\xE8" => '&#232;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#234;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#236;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#239;',
-	"\xF0" => '&#273;',
-	"\xF1" => '&#324;',
-	"\xF2" => '&#242;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#337;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#347;',
-	"\xF8" => '&#369;',
-	"\xF9" => '&#249;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#251;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#281;',
-	"\xFE" => '&#539;',
-	"\xFF" => '&#255;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#260;',
+        "\xA2" => '&#261;',
+        "\xA3" => '&#321;',
+        "\xA4" => '&#8364;',
+        "\xA5" => '&#8222;',
+        "\xA6" => '&#352;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#353;',
+        "\xA9" => '&#169;',
+        "\xAA" => '&#536;',
+        "\xAB" => '&#171;',
+        "\xAC" => '&#377;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#378;',
+        "\xAF" => '&#379;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#177;',
+        "\xB2" => '&#268;',
+        "\xB3" => '&#322;',
+        "\xB4" => '&#381;',
+        "\xB5" => '&#8221;',
+        "\xB6" => '&#182;',
+        "\xB7" => '&#183;',
+        "\xB8" => '&#382;',
+        "\xB9" => '&#269;',
+        "\xBA" => '&#537;',
+        "\xBB" => '&#187;',
+        "\xBC" => '&#338;',
+        "\xBD" => '&#339;',
+        "\xBE" => '&#376;',
+        "\xBF" => '&#380;',
+        "\xC0" => '&#192;',
+        "\xC1" => '&#193;',
+        "\xC2" => '&#194;',
+        "\xC3" => '&#258;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#262;',
+        "\xC6" => '&#198;',
+        "\xC7" => '&#199;',
+        "\xC8" => '&#200;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#202;',
+        "\xCB" => '&#203;',
+        "\xCC" => '&#204;',
+        "\xCD" => '&#205;',
+        "\xCE" => '&#206;',
+        "\xCF" => '&#207;',
+        "\xD0" => '&#272;',
+        "\xD1" => '&#323;',
+        "\xD2" => '&#210;',
+        "\xD3" => '&#211;',
+        "\xD4" => '&#212;',
+        "\xD5" => '&#336;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#346;',
+        "\xD8" => '&#368;',
+        "\xD9" => '&#217;',
+        "\xDA" => '&#218;',
+        "\xDB" => '&#219;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#280;',
+        "\xDE" => '&#538;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#224;',
+        "\xE1" => '&#225;',
+        "\xE2" => '&#226;',
+        "\xE3" => '&#259;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#263;',
+        "\xE6" => '&#230;',
+        "\xE7" => '&#231;',
+        "\xE8" => '&#232;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#234;',
+        "\xEB" => '&#235;',
+        "\xEC" => '&#236;',
+        "\xED" => '&#237;',
+        "\xEE" => '&#238;',
+        "\xEF" => '&#239;',
+        "\xF0" => '&#273;',
+        "\xF1" => '&#324;',
+        "\xF2" => '&#242;',
+        "\xF3" => '&#243;',
+        "\xF4" => '&#244;',
+        "\xF5" => '&#337;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#347;',
+        "\xF8" => '&#369;',
+        "\xF9" => '&#249;',
+        "\xFA" => '&#250;',
+        "\xFB" => '&#251;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#281;',
+        "\xFE" => '&#539;',
+        "\xFF" => '&#255;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_16), array_values($iso8859_16), $string);
     $string = str_replace(array_keys($iso8859_16), array_values($iso8859_16), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 112 - 114
functions/decode/iso_8859_2.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,113 +51,111 @@ function charset_decode_iso_8859_2 ($string) {
     if (strtolower($default_charset) == 'iso-8859-2')
     if (strtolower($default_charset) == 'iso-8859-2')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-2'))
         return $string;
         return $string;
 
 
     $iso8859_2 = array(
     $iso8859_2 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#260;',
-	"\xA2" => '&#728;',
-	"\xA3" => '&#321;',
-	"\xA4" => '&#164;',
-	"\xA5" => '&#317;',
-	"\xA6" => '&#346;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#168;',
-	"\xA9" => '&#352;',
-	"\xAA" => '&#350;',
-	"\xAB" => '&#356;',
-	"\xAC" => '&#377;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#381;',
-	"\xAF" => '&#379;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#261;',
-	"\xB2" => '&#731;',
-	"\xB3" => '&#322;',
-	"\xB4" => '&#180;',
-	"\xB5" => '&#318;',
-	"\xB6" => '&#347;',
-	"\xB7" => '&#711;',
-	"\xB8" => '&#184;',
-	"\xB9" => '&#353;',
-	"\xBA" => '&#351;',
-	"\xBB" => '&#357;',
-	"\xBC" => '&#378;',
-	"\xBD" => '&#733;',
-	"\xBE" => '&#382;',
-	"\xBF" => '&#380;',
-	"\xC0" => '&#340;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC3" => '&#258;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#313;',
-	"\xC6" => '&#262;',
-	"\xC7" => '&#199;',
-	"\xC8" => '&#268;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#280;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#282;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#270;',
-	"\xD0" => '&#272;',
-	"\xD1" => '&#323;',
-	"\xD2" => '&#327;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#336;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#215;',
-	"\xD8" => '&#344;',
-	"\xD9" => '&#366;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#368;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#221;',
-	"\xDE" => '&#354;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#341;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE3" => '&#259;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#314;',
-	"\xE6" => '&#263;',
-	"\xE7" => '&#231;',
-	"\xE8" => '&#269;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#281;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#283;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#271;',
-	"\xF0" => '&#273;',
-	"\xF1" => '&#324;',
-	"\xF2" => '&#328;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#337;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#247;',
-	"\xF8" => '&#345;',
-	"\xF9" => '&#367;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#369;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#253;',
-	"\xFE" => '&#355;',
-	"\xFF" => '&#729;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#260;',
+        "\xA2" => '&#728;',
+        "\xA3" => '&#321;',
+        "\xA4" => '&#164;',
+        "\xA5" => '&#317;',
+        "\xA6" => '&#346;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#168;',
+        "\xA9" => '&#352;',
+        "\xAA" => '&#350;',
+        "\xAB" => '&#356;',
+        "\xAC" => '&#377;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#381;',
+        "\xAF" => '&#379;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#261;',
+        "\xB2" => '&#731;',
+        "\xB3" => '&#322;',
+        "\xB4" => '&#180;',
+        "\xB5" => '&#318;',
+        "\xB6" => '&#347;',
+        "\xB7" => '&#711;',
+        "\xB8" => '&#184;',
+        "\xB9" => '&#353;',
+        "\xBA" => '&#351;',
+        "\xBB" => '&#357;',
+        "\xBC" => '&#378;',
+        "\xBD" => '&#733;',
+        "\xBE" => '&#382;',
+        "\xBF" => '&#380;',
+        "\xC0" => '&#340;',
+        "\xC1" => '&#193;',
+        "\xC2" => '&#194;',
+        "\xC3" => '&#258;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#313;',
+        "\xC6" => '&#262;',
+        "\xC7" => '&#199;',
+        "\xC8" => '&#268;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#280;',
+        "\xCB" => '&#203;',
+        "\xCC" => '&#282;',
+        "\xCD" => '&#205;',
+        "\xCE" => '&#206;',
+        "\xCF" => '&#270;',
+        "\xD0" => '&#272;',
+        "\xD1" => '&#323;',
+        "\xD2" => '&#327;',
+        "\xD3" => '&#211;',
+        "\xD4" => '&#212;',
+        "\xD5" => '&#336;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#215;',
+        "\xD8" => '&#344;',
+        "\xD9" => '&#366;',
+        "\xDA" => '&#218;',
+        "\xDB" => '&#368;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#221;',
+        "\xDE" => '&#354;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#341;',
+        "\xE1" => '&#225;',
+        "\xE2" => '&#226;',
+        "\xE3" => '&#259;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#314;',
+        "\xE6" => '&#263;',
+        "\xE7" => '&#231;',
+        "\xE8" => '&#269;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#281;',
+        "\xEB" => '&#235;',
+        "\xEC" => '&#283;',
+        "\xED" => '&#237;',
+        "\xEE" => '&#238;',
+        "\xEF" => '&#271;',
+        "\xF0" => '&#273;',
+        "\xF1" => '&#324;',
+        "\xF2" => '&#328;',
+        "\xF3" => '&#243;',
+        "\xF4" => '&#244;',
+        "\xF5" => '&#337;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#247;',
+        "\xF8" => '&#345;',
+        "\xF9" => '&#367;',
+        "\xFA" => '&#250;',
+        "\xFB" => '&#369;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#253;',
+        "\xFE" => '&#355;',
+        "\xFF" => '&#729;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_2), array_values($iso8859_2), $string);
     $string = str_replace(array_keys($iso8859_2), array_values($iso8859_2), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 105 - 107
functions/decode/iso_8859_3.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,106 +51,104 @@ function charset_decode_iso_8859_3 ($string) {
     if (strtolower($default_charset) == 'iso-8859-3')
     if (strtolower($default_charset) == 'iso-8859-3')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-3'))
         return $string;
         return $string;
 
 
     $iso8859_3 = array(
     $iso8859_3 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#294;',
-	"\xA2" => '&#728;',
-	"\xA3" => '&#163;',
-	"\xA4" => '&#164;',
-	"\xA6" => '&#292;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#168;',
-	"\xA9" => '&#304;',
-	"\xAA" => '&#350;',
-	"\xAB" => '&#286;',
-	"\xAC" => '&#308;',
-	"\xAD" => '&#173;',
-	"\xAF" => '&#379;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#295;',
-	"\xB2" => '&#178;',
-	"\xB3" => '&#179;',
-	"\xB4" => '&#180;',
-	"\xB5" => '&#181;',
-	"\xB6" => '&#293;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#184;',
-	"\xB9" => '&#305;',
-	"\xBA" => '&#351;',
-	"\xBB" => '&#287;',
-	"\xBC" => '&#309;',
-	"\xBD" => '&#189;',
-	"\xBF" => '&#380;',
-	"\xC0" => '&#192;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#266;',
-	"\xC6" => '&#264;',
-	"\xC7" => '&#199;',
-	"\xC8" => '&#200;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#202;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#204;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#207;',
-	"\xD1" => '&#209;',
-	"\xD2" => '&#210;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#288;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#215;',
-	"\xD8" => '&#284;',
-	"\xD9" => '&#217;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#219;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#364;',
-	"\xDE" => '&#348;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#224;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#267;',
-	"\xE6" => '&#265;',
-	"\xE7" => '&#231;',
-	"\xE8" => '&#232;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#234;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#236;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#239;',
-	"\xF1" => '&#241;',
-	"\xF2" => '&#242;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#289;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#247;',
-	"\xF8" => '&#285;',
-	"\xF9" => '&#249;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#251;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#365;',
-	"\xFE" => '&#349;',
-	"\xFF" => '&#729;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#294;',
+        "\xA2" => '&#728;',
+        "\xA3" => '&#163;',
+        "\xA4" => '&#164;',
+        "\xA6" => '&#292;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#168;',
+        "\xA9" => '&#304;',
+        "\xAA" => '&#350;',
+        "\xAB" => '&#286;',
+        "\xAC" => '&#308;',
+        "\xAD" => '&#173;',
+        "\xAF" => '&#379;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#295;',
+        "\xB2" => '&#178;',
+        "\xB3" => '&#179;',
+        "\xB4" => '&#180;',
+        "\xB5" => '&#181;',
+        "\xB6" => '&#293;',
+        "\xB7" => '&#183;',
+        "\xB8" => '&#184;',
+        "\xB9" => '&#305;',
+        "\xBA" => '&#351;',
+        "\xBB" => '&#287;',
+        "\xBC" => '&#309;',
+        "\xBD" => '&#189;',
+        "\xBF" => '&#380;',
+        "\xC0" => '&#192;',
+        "\xC1" => '&#193;',
+        "\xC2" => '&#194;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#266;',
+        "\xC6" => '&#264;',
+        "\xC7" => '&#199;',
+        "\xC8" => '&#200;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#202;',
+        "\xCB" => '&#203;',
+        "\xCC" => '&#204;',
+        "\xCD" => '&#205;',
+        "\xCE" => '&#206;',
+        "\xCF" => '&#207;',
+        "\xD1" => '&#209;',
+        "\xD2" => '&#210;',
+        "\xD3" => '&#211;',
+        "\xD4" => '&#212;',
+        "\xD5" => '&#288;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#215;',
+        "\xD8" => '&#284;',
+        "\xD9" => '&#217;',
+        "\xDA" => '&#218;',
+        "\xDB" => '&#219;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#364;',
+        "\xDE" => '&#348;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#224;',
+        "\xE1" => '&#225;',
+        "\xE2" => '&#226;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#267;',
+        "\xE6" => '&#265;',
+        "\xE7" => '&#231;',
+        "\xE8" => '&#232;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#234;',
+        "\xEB" => '&#235;',
+        "\xEC" => '&#236;',
+        "\xED" => '&#237;',
+        "\xEE" => '&#238;',
+        "\xEF" => '&#239;',
+        "\xF1" => '&#241;',
+        "\xF2" => '&#242;',
+        "\xF3" => '&#243;',
+        "\xF4" => '&#244;',
+        "\xF5" => '&#289;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#247;',
+        "\xF8" => '&#285;',
+        "\xF9" => '&#249;',
+        "\xFA" => '&#250;',
+        "\xFB" => '&#251;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#365;',
+        "\xFE" => '&#349;',
+        "\xFF" => '&#729;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string);
     $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 112 - 114
functions/decode/iso_8859_4.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,113 +51,111 @@ function charset_decode_iso_8859_4 ($string) {
     if (strtolower($default_charset) == 'iso-8859-4')
     if (strtolower($default_charset) == 'iso-8859-4')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-4'))
         return $string;
         return $string;
 
 
     $iso8859_4 = array(
     $iso8859_4 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#260;',
-	"\xA2" => '&#312;',
-	"\xA3" => '&#342;',
-	"\xA4" => '&#164;',
-	"\xA5" => '&#296;',
-	"\xA6" => '&#315;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#168;',
-	"\xA9" => '&#352;',
-	"\xAA" => '&#274;',
-	"\xAB" => '&#290;',
-	"\xAC" => '&#358;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#381;',
-	"\xAF" => '&#175;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#261;',
-	"\xB2" => '&#731;',
-	"\xB3" => '&#343;',
-	"\xB4" => '&#180;',
-	"\xB5" => '&#297;',
-	"\xB6" => '&#316;',
-	"\xB7" => '&#711;',
-	"\xB8" => '&#184;',
-	"\xB9" => '&#353;',
-	"\xBA" => '&#275;',
-	"\xBB" => '&#291;',
-	"\xBC" => '&#359;',
-	"\xBD" => '&#330;',
-	"\xBE" => '&#382;',
-	"\xBF" => '&#331;',
-	"\xC0" => '&#256;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC3" => '&#195;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#197;',
-	"\xC6" => '&#198;',
-	"\xC7" => '&#302;',
-	"\xC8" => '&#268;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#280;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#278;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#298;',
-	"\xD0" => '&#272;',
-	"\xD1" => '&#325;',
-	"\xD2" => '&#332;',
-	"\xD3" => '&#310;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#213;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#215;',
-	"\xD8" => '&#216;',
-	"\xD9" => '&#370;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#219;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#360;',
-	"\xDE" => '&#362;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#257;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE3" => '&#227;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#229;',
-	"\xE6" => '&#230;',
-	"\xE7" => '&#303;',
-	"\xE8" => '&#269;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#281;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#279;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#299;',
-	"\xF0" => '&#273;',
-	"\xF1" => '&#326;',
-	"\xF2" => '&#333;',
-	"\xF3" => '&#311;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#245;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#247;',
-	"\xF8" => '&#248;',
-	"\xF9" => '&#371;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#251;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#361;',
-	"\xFE" => '&#363;',
-	"\xFF" => '&#729;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#260;',
+        "\xA2" => '&#312;',
+        "\xA3" => '&#342;',
+        "\xA4" => '&#164;',
+        "\xA5" => '&#296;',
+        "\xA6" => '&#315;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#168;',
+        "\xA9" => '&#352;',
+        "\xAA" => '&#274;',
+        "\xAB" => '&#290;',
+        "\xAC" => '&#358;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#381;',
+        "\xAF" => '&#175;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#261;',
+        "\xB2" => '&#731;',
+        "\xB3" => '&#343;',
+        "\xB4" => '&#180;',
+        "\xB5" => '&#297;',
+        "\xB6" => '&#316;',
+        "\xB7" => '&#711;',
+        "\xB8" => '&#184;',
+        "\xB9" => '&#353;',
+        "\xBA" => '&#275;',
+        "\xBB" => '&#291;',
+        "\xBC" => '&#359;',
+        "\xBD" => '&#330;',
+        "\xBE" => '&#382;',
+        "\xBF" => '&#331;',
+        "\xC0" => '&#256;',
+        "\xC1" => '&#193;',
+        "\xC2" => '&#194;',
+        "\xC3" => '&#195;',
+        "\xC4" => '&#196;',
+        "\xC5" => '&#197;',
+        "\xC6" => '&#198;',
+        "\xC7" => '&#302;',
+        "\xC8" => '&#268;',
+        "\xC9" => '&#201;',
+        "\xCA" => '&#280;',
+        "\xCB" => '&#203;',
+        "\xCC" => '&#278;',
+        "\xCD" => '&#205;',
+        "\xCE" => '&#206;',
+        "\xCF" => '&#298;',
+        "\xD0" => '&#272;',
+        "\xD1" => '&#325;',
+        "\xD2" => '&#332;',
+        "\xD3" => '&#310;',
+        "\xD4" => '&#212;',
+        "\xD5" => '&#213;',
+        "\xD6" => '&#214;',
+        "\xD7" => '&#215;',
+        "\xD8" => '&#216;',
+        "\xD9" => '&#370;',
+        "\xDA" => '&#218;',
+        "\xDB" => '&#219;',
+        "\xDC" => '&#220;',
+        "\xDD" => '&#360;',
+        "\xDE" => '&#362;',
+        "\xDF" => '&#223;',
+        "\xE0" => '&#257;',
+        "\xE1" => '&#225;',
+        "\xE2" => '&#226;',
+        "\xE3" => '&#227;',
+        "\xE4" => '&#228;',
+        "\xE5" => '&#229;',
+        "\xE6" => '&#230;',
+        "\xE7" => '&#303;',
+        "\xE8" => '&#269;',
+        "\xE9" => '&#233;',
+        "\xEA" => '&#281;',
+        "\xEB" => '&#235;',
+        "\xEC" => '&#279;',
+        "\xED" => '&#237;',
+        "\xEE" => '&#238;',
+        "\xEF" => '&#299;',
+        "\xF0" => '&#273;',
+        "\xF1" => '&#326;',
+        "\xF2" => '&#333;',
+        "\xF3" => '&#311;',
+        "\xF4" => '&#244;',
+        "\xF5" => '&#245;',
+        "\xF6" => '&#246;',
+        "\xF7" => '&#247;',
+        "\xF8" => '&#248;',
+        "\xF9" => '&#371;',
+        "\xFA" => '&#250;',
+        "\xFB" => '&#251;',
+        "\xFC" => '&#252;',
+        "\xFD" => '&#361;',
+        "\xFE" => '&#363;',
+        "\xFF" => '&#729;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_4), array_values($iso8859_4), $string);
     $string = str_replace(array_keys($iso8859_4), array_values($iso8859_4), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 112 - 114
functions/decode/iso_8859_5.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,113 +51,111 @@ function charset_decode_iso_8859_5 ($string) {
     if (strtolower($default_charset) == 'iso-8859-5')
     if (strtolower($default_charset) == 'iso-8859-5')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-5'))
         return $string;
         return $string;
 
 
     $iso8859_5 = array(
     $iso8859_5 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#1025;',
-	"\xA2" => '&#1026;',
-	"\xA3" => '&#1027;',
-	"\xA4" => '&#1028;',
-	"\xA5" => '&#1029;',
-	"\xA6" => '&#1030;',
-	"\xA7" => '&#1031;',
-	"\xA8" => '&#1032;',
-	"\xA9" => '&#1033;',
-	"\xAA" => '&#1034;',
-	"\xAB" => '&#1035;',
-	"\xAC" => '&#1036;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#1038;',
-	"\xAF" => '&#1039;',
-	"\xB0" => '&#1040;',
-	"\xB1" => '&#1041;',
-	"\xB2" => '&#1042;',
-	"\xB3" => '&#1043;',
-	"\xB4" => '&#1044;',
-	"\xB5" => '&#1045;',
-	"\xB6" => '&#1046;',
-	"\xB7" => '&#1047;',
-	"\xB8" => '&#1048;',
-	"\xB9" => '&#1049;',
-	"\xBA" => '&#1050;',
-	"\xBB" => '&#1051;',
-	"\xBC" => '&#1052;',
-	"\xBD" => '&#1053;',
-	"\xBE" => '&#1054;',
-	"\xBF" => '&#1055;',
-	"\xC0" => '&#1056;',
-	"\xC1" => '&#1057;',
-	"\xC2" => '&#1058;',
-	"\xC3" => '&#1059;',
-	"\xC4" => '&#1060;',
-	"\xC5" => '&#1061;',
-	"\xC6" => '&#1062;',
-	"\xC7" => '&#1063;',
-	"\xC8" => '&#1064;',
-	"\xC9" => '&#1065;',
-	"\xCA" => '&#1066;',
-	"\xCB" => '&#1067;',
-	"\xCC" => '&#1068;',
-	"\xCD" => '&#1069;',
-	"\xCE" => '&#1070;',
-	"\xCF" => '&#1071;',
-	"\xD0" => '&#1072;',
-	"\xD1" => '&#1073;',
-	"\xD2" => '&#1074;',
-	"\xD3" => '&#1075;',
-	"\xD4" => '&#1076;',
-	"\xD5" => '&#1077;',
-	"\xD6" => '&#1078;',
-	"\xD7" => '&#1079;',
-	"\xD8" => '&#1080;',
-	"\xD9" => '&#1081;',
-	"\xDA" => '&#1082;',
-	"\xDB" => '&#1083;',
-	"\xDC" => '&#1084;',
-	"\xDD" => '&#1085;',
-	"\xDE" => '&#1086;',
-	"\xDF" => '&#1087;',
-	"\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" => '&#8470;',
-	"\xF1" => '&#1105;',
-	"\xF2" => '&#1106;',
-	"\xF3" => '&#1107;',
-	"\xF4" => '&#1108;',
-	"\xF5" => '&#1109;',
-	"\xF6" => '&#1110;',
-	"\xF7" => '&#1111;',
-	"\xF8" => '&#1112;',
-	"\xF9" => '&#1113;',
-	"\xFA" => '&#1114;',
-	"\xFB" => '&#1115;',
-	"\xFC" => '&#1116;',
-	"\xFD" => '&#167;',
-	"\xFE" => '&#1118;',
-	"\xFF" => '&#1119;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#1025;',
+        "\xA2" => '&#1026;',
+        "\xA3" => '&#1027;',
+        "\xA4" => '&#1028;',
+        "\xA5" => '&#1029;',
+        "\xA6" => '&#1030;',
+        "\xA7" => '&#1031;',
+        "\xA8" => '&#1032;',
+        "\xA9" => '&#1033;',
+        "\xAA" => '&#1034;',
+        "\xAB" => '&#1035;',
+        "\xAC" => '&#1036;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#1038;',
+        "\xAF" => '&#1039;',
+        "\xB0" => '&#1040;',
+        "\xB1" => '&#1041;',
+        "\xB2" => '&#1042;',
+        "\xB3" => '&#1043;',
+        "\xB4" => '&#1044;',
+        "\xB5" => '&#1045;',
+        "\xB6" => '&#1046;',
+        "\xB7" => '&#1047;',
+        "\xB8" => '&#1048;',
+        "\xB9" => '&#1049;',
+        "\xBA" => '&#1050;',
+        "\xBB" => '&#1051;',
+        "\xBC" => '&#1052;',
+        "\xBD" => '&#1053;',
+        "\xBE" => '&#1054;',
+        "\xBF" => '&#1055;',
+        "\xC0" => '&#1056;',
+        "\xC1" => '&#1057;',
+        "\xC2" => '&#1058;',
+        "\xC3" => '&#1059;',
+        "\xC4" => '&#1060;',
+        "\xC5" => '&#1061;',
+        "\xC6" => '&#1062;',
+        "\xC7" => '&#1063;',
+        "\xC8" => '&#1064;',
+        "\xC9" => '&#1065;',
+        "\xCA" => '&#1066;',
+        "\xCB" => '&#1067;',
+        "\xCC" => '&#1068;',
+        "\xCD" => '&#1069;',
+        "\xCE" => '&#1070;',
+        "\xCF" => '&#1071;',
+        "\xD0" => '&#1072;',
+        "\xD1" => '&#1073;',
+        "\xD2" => '&#1074;',
+        "\xD3" => '&#1075;',
+        "\xD4" => '&#1076;',
+        "\xD5" => '&#1077;',
+        "\xD6" => '&#1078;',
+        "\xD7" => '&#1079;',
+        "\xD8" => '&#1080;',
+        "\xD9" => '&#1081;',
+        "\xDA" => '&#1082;',
+        "\xDB" => '&#1083;',
+        "\xDC" => '&#1084;',
+        "\xDD" => '&#1085;',
+        "\xDE" => '&#1086;',
+        "\xDF" => '&#1087;',
+        "\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" => '&#8470;',
+        "\xF1" => '&#1105;',
+        "\xF2" => '&#1106;',
+        "\xF3" => '&#1107;',
+        "\xF4" => '&#1108;',
+        "\xF5" => '&#1109;',
+        "\xF6" => '&#1110;',
+        "\xF7" => '&#1111;',
+        "\xF8" => '&#1112;',
+        "\xF9" => '&#1113;',
+        "\xFA" => '&#1114;',
+        "\xFB" => '&#1115;',
+        "\xFC" => '&#1116;',
+        "\xFD" => '&#167;',
+        "\xFE" => '&#1118;',
+        "\xFF" => '&#1119;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_5), array_values($iso8859_5), $string);
     $string = str_replace(array_keys($iso8859_5), array_values($iso8859_5), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 67 - 69
functions/decode/iso_8859_6.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,68 +51,66 @@ function charset_decode_iso_8859_6 ($string) {
     if (strtolower($default_charset) == 'iso-8859-6')
     if (strtolower($default_charset) == 'iso-8859-6')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-6'))
         return $string;
         return $string;
 
 
     $iso8859_6 = array(
     $iso8859_6 = array(
-	"\xA0" => '&#160;',
-	"\xA4" => '&#164;',
-	"\xAC" => '&#1548;',
-	"\xAD" => '&#173;',
-	"\xBB" => '&#1563;',
-	"\xBF" => '&#1567;',
-	"\xC1" => '&#1569;',
-	"\xC2" => '&#1570;',
-	"\xC3" => '&#1571;',
-	"\xC4" => '&#1572;',
-	"\xC5" => '&#1573;',
-	"\xC6" => '&#1574;',
-	"\xC7" => '&#1575;',
-	"\xC8" => '&#1576;',
-	"\xC9" => '&#1577;',
-	"\xCA" => '&#1578;',
-	"\xCB" => '&#1579;',
-	"\xCC" => '&#1580;',
-	"\xCD" => '&#1581;',
-	"\xCE" => '&#1582;',
-	"\xCF" => '&#1583;',
-	"\xD0" => '&#1584;',
-	"\xD1" => '&#1585;',
-	"\xD2" => '&#1586;',
-	"\xD3" => '&#1587;',
-	"\xD4" => '&#1588;',
-	"\xD5" => '&#1589;',
-	"\xD6" => '&#1590;',
-	"\xD7" => '&#1591;',
-	"\xD8" => '&#1592;',
-	"\xD9" => '&#1593;',
-	"\xDA" => '&#1594;',
-	"\xE0" => '&#1600;',
-	"\xE1" => '&#1601;',
-	"\xE2" => '&#1602;',
-	"\xE3" => '&#1603;',
-	"\xE4" => '&#1604;',
-	"\xE5" => '&#1605;',
-	"\xE6" => '&#1606;',
-	"\xE7" => '&#1607;',
-	"\xE8" => '&#1608;',
-	"\xE9" => '&#1609;',
-	"\xEA" => '&#1610;',
-	"\xEB" => '&#1611;',
-	"\xEC" => '&#1612;',
-	"\xED" => '&#1613;',
-	"\xEE" => '&#1614;',
-	"\xEF" => '&#1615;',
-	"\xF0" => '&#1616;',
-	"\xF1" => '&#1617;',
-	"\xF2" => '&#1618;'
+        "\xA0" => '&#160;',
+        "\xA4" => '&#164;',
+        "\xAC" => '&#1548;',
+        "\xAD" => '&#173;',
+        "\xBB" => '&#1563;',
+        "\xBF" => '&#1567;',
+        "\xC1" => '&#1569;',
+        "\xC2" => '&#1570;',
+        "\xC3" => '&#1571;',
+        "\xC4" => '&#1572;',
+        "\xC5" => '&#1573;',
+        "\xC6" => '&#1574;',
+        "\xC7" => '&#1575;',
+        "\xC8" => '&#1576;',
+        "\xC9" => '&#1577;',
+        "\xCA" => '&#1578;',
+        "\xCB" => '&#1579;',
+        "\xCC" => '&#1580;',
+        "\xCD" => '&#1581;',
+        "\xCE" => '&#1582;',
+        "\xCF" => '&#1583;',
+        "\xD0" => '&#1584;',
+        "\xD1" => '&#1585;',
+        "\xD2" => '&#1586;',
+        "\xD3" => '&#1587;',
+        "\xD4" => '&#1588;',
+        "\xD5" => '&#1589;',
+        "\xD6" => '&#1590;',
+        "\xD7" => '&#1591;',
+        "\xD8" => '&#1592;',
+        "\xD9" => '&#1593;',
+        "\xDA" => '&#1594;',
+        "\xE0" => '&#1600;',
+        "\xE1" => '&#1601;',
+        "\xE2" => '&#1602;',
+        "\xE3" => '&#1603;',
+        "\xE4" => '&#1604;',
+        "\xE5" => '&#1605;',
+        "\xE6" => '&#1606;',
+        "\xE7" => '&#1607;',
+        "\xE8" => '&#1608;',
+        "\xE9" => '&#1609;',
+        "\xEA" => '&#1610;',
+        "\xEB" => '&#1611;',
+        "\xEC" => '&#1612;',
+        "\xED" => '&#1613;',
+        "\xEE" => '&#1614;',
+        "\xEF" => '&#1615;',
+        "\xF0" => '&#1616;',
+        "\xF1" => '&#1617;',
+        "\xF2" => '&#1618;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_6), array_values($iso8859_6), $string);
     $string = str_replace(array_keys($iso8859_6), array_values($iso8859_6), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 106 - 108
functions/decode/iso_8859_7.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,107 +51,105 @@ function charset_decode_iso_8859_7 ($string) {
     if (strtolower($default_charset) == 'iso-8859-7')
     if (strtolower($default_charset) == 'iso-8859-7')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-7'))
         return $string;
         return $string;
 
 
     $iso8859_7 = array(
     $iso8859_7 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#8216;',
-	"\xA2" => '&#8217;',
-	"\xA3" => '&#163;',
-	"\xA6" => '&#166;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#168;',
-	"\xA9" => '&#169;',
-	"\xAB" => '&#171;',
-	"\xAC" => '&#172;',
-	"\xAD" => '&#173;',
-	"\xAF" => '&#8213;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#177;',
-	"\xB2" => '&#178;',
-	"\xB3" => '&#179;',
-	"\xB4" => '&#900;',
-	"\xB5" => '&#901;',
-	"\xB6" => '&#902;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#904;',
-	"\xB9" => '&#905;',
-	"\xBA" => '&#906;',
-	"\xBB" => '&#187;',
-	"\xBC" => '&#908;',
-	"\xBD" => '&#189;',
-	"\xBE" => '&#910;',
-	"\xBF" => '&#911;',
-	"\xC0" => '&#912;',
-	"\xC1" => '&#913;',
-	"\xC2" => '&#914;',
-	"\xC3" => '&#915;',
-	"\xC4" => '&#916;',
-	"\xC5" => '&#917;',
-	"\xC6" => '&#918;',
-	"\xC7" => '&#919;',
-	"\xC8" => '&#920;',
-	"\xC9" => '&#921;',
-	"\xCA" => '&#922;',
-	"\xCB" => '&#923;',
-	"\xCC" => '&#924;',
-	"\xCD" => '&#925;',
-	"\xCE" => '&#926;',
-	"\xCF" => '&#927;',
-	"\xD0" => '&#928;',
-	"\xD1" => '&#929;',
-	"\xD3" => '&#931;',
-	"\xD4" => '&#932;',
-	"\xD5" => '&#933;',
-	"\xD6" => '&#934;',
-	"\xD7" => '&#935;',
-	"\xD8" => '&#936;',
-	"\xD9" => '&#937;',
-	"\xDA" => '&#938;',
-	"\xDB" => '&#939;',
-	"\xDC" => '&#940;',
-	"\xDD" => '&#941;',
-	"\xDE" => '&#942;',
-	"\xDF" => '&#943;',
-	"\xE0" => '&#944;',
-	"\xE1" => '&#945;',
-	"\xE2" => '&#946;',
-	"\xE3" => '&#947;',
-	"\xE4" => '&#948;',
-	"\xE5" => '&#949;',
-	"\xE6" => '&#950;',
-	"\xE7" => '&#951;',
-	"\xE8" => '&#952;',
-	"\xE9" => '&#953;',
-	"\xEA" => '&#954;',
-	"\xEB" => '&#955;',
-	"\xEC" => '&#956;',
-	"\xED" => '&#957;',
-	"\xEE" => '&#958;',
-	"\xEF" => '&#959;',
-	"\xF0" => '&#960;',
-	"\xF1" => '&#961;',
-	"\xF2" => '&#962;',
-	"\xF3" => '&#963;',
-	"\xF4" => '&#964;',
-	"\xF5" => '&#965;',
-	"\xF6" => '&#966;',
-	"\xF7" => '&#967;',
-	"\xF8" => '&#968;',
-	"\xF9" => '&#969;',
-	"\xFA" => '&#970;',
-	"\xFB" => '&#971;',
-	"\xFC" => '&#972;',
-	"\xFD" => '&#973;',
-	"\xFE" => '&#974;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#8216;',
+        "\xA2" => '&#8217;',
+        "\xA3" => '&#163;',
+        "\xA6" => '&#166;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#168;',
+        "\xA9" => '&#169;',
+        "\xAB" => '&#171;',
+        "\xAC" => '&#172;',
+        "\xAD" => '&#173;',
+        "\xAF" => '&#8213;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#177;',
+        "\xB2" => '&#178;',
+        "\xB3" => '&#179;',
+        "\xB4" => '&#900;',
+        "\xB5" => '&#901;',
+        "\xB6" => '&#902;',
+        "\xB7" => '&#183;',
+        "\xB8" => '&#904;',
+        "\xB9" => '&#905;',
+        "\xBA" => '&#906;',
+        "\xBB" => '&#187;',
+        "\xBC" => '&#908;',
+        "\xBD" => '&#189;',
+        "\xBE" => '&#910;',
+        "\xBF" => '&#911;',
+        "\xC0" => '&#912;',
+        "\xC1" => '&#913;',
+        "\xC2" => '&#914;',
+        "\xC3" => '&#915;',
+        "\xC4" => '&#916;',
+        "\xC5" => '&#917;',
+        "\xC6" => '&#918;',
+        "\xC7" => '&#919;',
+        "\xC8" => '&#920;',
+        "\xC9" => '&#921;',
+        "\xCA" => '&#922;',
+        "\xCB" => '&#923;',
+        "\xCC" => '&#924;',
+        "\xCD" => '&#925;',
+        "\xCE" => '&#926;',
+        "\xCF" => '&#927;',
+        "\xD0" => '&#928;',
+        "\xD1" => '&#929;',
+        "\xD3" => '&#931;',
+        "\xD4" => '&#932;',
+        "\xD5" => '&#933;',
+        "\xD6" => '&#934;',
+        "\xD7" => '&#935;',
+        "\xD8" => '&#936;',
+        "\xD9" => '&#937;',
+        "\xDA" => '&#938;',
+        "\xDB" => '&#939;',
+        "\xDC" => '&#940;',
+        "\xDD" => '&#941;',
+        "\xDE" => '&#942;',
+        "\xDF" => '&#943;',
+        "\xE0" => '&#944;',
+        "\xE1" => '&#945;',
+        "\xE2" => '&#946;',
+        "\xE3" => '&#947;',
+        "\xE4" => '&#948;',
+        "\xE5" => '&#949;',
+        "\xE6" => '&#950;',
+        "\xE7" => '&#951;',
+        "\xE8" => '&#952;',
+        "\xE9" => '&#953;',
+        "\xEA" => '&#954;',
+        "\xEB" => '&#955;',
+        "\xEC" => '&#956;',
+        "\xED" => '&#957;',
+        "\xEE" => '&#958;',
+        "\xEF" => '&#959;',
+        "\xF0" => '&#960;',
+        "\xF1" => '&#961;',
+        "\xF2" => '&#962;',
+        "\xF3" => '&#963;',
+        "\xF4" => '&#964;',
+        "\xF5" => '&#965;',
+        "\xF6" => '&#966;',
+        "\xF7" => '&#967;',
+        "\xF8" => '&#968;',
+        "\xF9" => '&#969;',
+        "\xFA" => '&#970;',
+        "\xFB" => '&#971;',
+        "\xFC" => '&#972;',
+        "\xFD" => '&#973;',
+        "\xFE" => '&#974;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_7), array_values($iso8859_7), $string);
     $string = str_replace(array_keys($iso8859_7), array_values($iso8859_7), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 76 - 78
functions/decode/iso_8859_8.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,77 +51,75 @@ function charset_decode_iso_8859_8 ($string) {
     if (strtolower($default_charset) == 'iso8859-8')
     if (strtolower($default_charset) == 'iso8859-8')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-8'))
         return $string;
         return $string;
 
 
     $iso8859_8 = array(
     $iso8859_8 = array(
-	"\xA0" => '&#160;',
-	"\xA2" => '&#162;',
-	"\xA3" => '&#163;',
-	"\xA4" => '&#164;',
-	"\xA5" => '&#165;',
-	"\xA6" => '&#166;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#168;',
-	"\xA9" => '&#169;',
-	"\xAA" => '&#215;',
-	"\xAB" => '&#171;',
-	"\xAC" => '&#172;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#174;',
-	"\xAF" => '&#175;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#177;',
-	"\xB2" => '&#178;',
-	"\xB3" => '&#179;',
-	"\xB4" => '&#180;',
-	"\xB5" => '&#181;',
-	"\xB6" => '&#182;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#184;',
-	"\xB9" => '&#185;',
-	"\xBA" => '&#247;',
-	"\xBB" => '&#187;',
-	"\xBC" => '&#188;',
-	"\xBD" => '&#189;',
-	"\xBE" => '&#190;',
-	"\xDF" => '&#8215;',
-	"\xE0" => '&#1488;',
-	"\xE1" => '&#1489;',
-	"\xE2" => '&#1490;',
-	"\xE3" => '&#1491;',
-	"\xE4" => '&#1492;',
-	"\xE5" => '&#1493;',
-	"\xE6" => '&#1494;',
-	"\xE7" => '&#1495;',
-	"\xE8" => '&#1496;',
-	"\xE9" => '&#1497;',
-	"\xEA" => '&#1498;',
-	"\xEB" => '&#1499;',
-	"\xEC" => '&#1500;',
-	"\xED" => '&#1501;',
-	"\xEE" => '&#1502;',
-	"\xEF" => '&#1503;',
-	"\xF0" => '&#1504;',
-	"\xF1" => '&#1505;',
-	"\xF2" => '&#1506;',
-	"\xF3" => '&#1507;',
-	"\xF4" => '&#1508;',
-	"\xF5" => '&#1509;',
-	"\xF6" => '&#1510;',
-	"\xF7" => '&#1511;',
-	"\xF8" => '&#1512;',
-	"\xF9" => '&#1513;',
-	"\xFA" => '&#1514;',
-	"\xFD" => '&#8206;',
-	"\xFE" => '&#8207;'
+        "\xA0" => '&#160;',
+        "\xA2" => '&#162;',
+        "\xA3" => '&#163;',
+        "\xA4" => '&#164;',
+        "\xA5" => '&#165;',
+        "\xA6" => '&#166;',
+        "\xA7" => '&#167;',
+        "\xA8" => '&#168;',
+        "\xA9" => '&#169;',
+        "\xAA" => '&#215;',
+        "\xAB" => '&#171;',
+        "\xAC" => '&#172;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#174;',
+        "\xAF" => '&#175;',
+        "\xB0" => '&#176;',
+        "\xB1" => '&#177;',
+        "\xB2" => '&#178;',
+        "\xB3" => '&#179;',
+        "\xB4" => '&#180;',
+        "\xB5" => '&#181;',
+        "\xB6" => '&#182;',
+        "\xB7" => '&#183;',
+        "\xB8" => '&#184;',
+        "\xB9" => '&#185;',
+        "\xBA" => '&#247;',
+        "\xBB" => '&#187;',
+        "\xBC" => '&#188;',
+        "\xBD" => '&#189;',
+        "\xBE" => '&#190;',
+        "\xDF" => '&#8215;',
+        "\xE0" => '&#1488;',
+        "\xE1" => '&#1489;',
+        "\xE2" => '&#1490;',
+        "\xE3" => '&#1491;',
+        "\xE4" => '&#1492;',
+        "\xE5" => '&#1493;',
+        "\xE6" => '&#1494;',
+        "\xE7" => '&#1495;',
+        "\xE8" => '&#1496;',
+        "\xE9" => '&#1497;',
+        "\xEA" => '&#1498;',
+        "\xEB" => '&#1499;',
+        "\xEC" => '&#1500;',
+        "\xED" => '&#1501;',
+        "\xEE" => '&#1502;',
+        "\xEF" => '&#1503;',
+        "\xF0" => '&#1504;',
+        "\xF1" => '&#1505;',
+        "\xF2" => '&#1506;',
+        "\xF3" => '&#1507;',
+        "\xF4" => '&#1508;',
+        "\xF5" => '&#1509;',
+        "\xF6" => '&#1510;',
+        "\xF7" => '&#1511;',
+        "\xF8" => '&#1512;',
+        "\xF9" => '&#1513;',
+        "\xFA" => '&#1514;',
+        "\xFD" => '&#8206;',
+        "\xFE" => '&#8207;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_8), array_values($iso8859_8), $string);
     $string = str_replace(array_keys($iso8859_8), array_values($iso8859_8), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 112 - 114
functions/decode/iso_8859_9.php

@@ -19,21 +19,21 @@
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *   Authors:          Ken Whistler <kenw@sybase.com>
  *
  *
  * Original copyright:
  * Original copyright:
- *	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
+ *  Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
  *
  *
- *	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- *	No claims are made as to fitness for any particular purpose.  No
- *	warranties of any kind are expressed or implied.  The recipient
- *	agrees to determine applicability of information provided.  If this
- *	file has been provided on optical media by Unicode, Inc., the sole
- *	remedy for any claim will be exchange of defective media within 90
- *	days of receipt.
+ *  This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+ *  No claims are made as to fitness for any particular purpose.  No
+ *  warranties of any kind are expressed or implied.  The recipient
+ *  agrees to determine applicability of information provided.  If this
+ *  file has been provided on optical media by Unicode, Inc., the sole
+ *  remedy for any claim will be exchange of defective media within 90
+ *  days of receipt.
  *
  *
- *	Unicode, Inc. hereby grants the right to freely use the information
- *	supplied in this file in the creation of products supporting the
- *	Unicode Standard, and to make copies of this file in any form for
- *	internal or external distribution as long as this notice remains
- *	attached.
+ *  Unicode, Inc. hereby grants the right to freely use the information
+ *  supplied in this file in the creation of products supporting the
+ *  Unicode Standard, and to make copies of this file in any form for
+ *  internal or external distribution as long as this notice remains
+ *  attached.
  *
  *
  * @version $Id$
  * @version $Id$
  * @package squirrelmail
  * @package squirrelmail
@@ -51,113 +51,111 @@ function charset_decode_iso_8859_9 ($string) {
     if (strtolower($default_charset) == 'iso8859-9')
     if (strtolower($default_charset) == 'iso8859-9')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO8859-* */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-8859-9'))
         return $string;
         return $string;
 
 
     $iso8859_9 = array(
     $iso8859_9 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#161;',
-	"\xA2" => '&#162;',
-	"\xA3" => '&#163;',
-	"\xA4" => '&#164;',
-	"\xA5" => '&#165;',
-	"\xA6" => '&#166;',
-	"\xA7" => '&#167;',
-	"\xA8" => '&#168;',
-	"\xA9" => '&#169;',
-	"\xAA" => '&#170;',
-	"\xAB" => '&#171;',
-	"\xAC" => '&#172;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#174;',
-	"\xAF" => '&#175;',
-	"\xB0" => '&#176;',
-	"\xB1" => '&#177;',
-	"\xB2" => '&#178;',
-	"\xB3" => '&#179;',
-	"\xB4" => '&#180;',
-	"\xB5" => '&#181;',
-	"\xB6" => '&#182;',
-	"\xB7" => '&#183;',
-	"\xB8" => '&#184;',
-	"\xB9" => '&#185;',
-	"\xBA" => '&#186;',
-	"\xBB" => '&#187;',
-	"\xBC" => '&#188;',
-	"\xBD" => '&#189;',
-	"\xBE" => '&#190;',
-	"\xBF" => '&#191;',
-	"\xC0" => '&#192;',
-	"\xC1" => '&#193;',
-	"\xC2" => '&#194;',
-	"\xC3" => '&#195;',
-	"\xC4" => '&#196;',
-	"\xC5" => '&#197;',
-	"\xC6" => '&#198;',
-	"\xC7" => '&#199;',
-	"\xC8" => '&#200;',
-	"\xC9" => '&#201;',
-	"\xCA" => '&#202;',
-	"\xCB" => '&#203;',
-	"\xCC" => '&#204;',
-	"\xCD" => '&#205;',
-	"\xCE" => '&#206;',
-	"\xCF" => '&#207;',
-	"\xD0" => '&#286;',
-	"\xD1" => '&#209;',
-	"\xD2" => '&#210;',
-	"\xD3" => '&#211;',
-	"\xD4" => '&#212;',
-	"\xD5" => '&#213;',
-	"\xD6" => '&#214;',
-	"\xD7" => '&#215;',
-	"\xD8" => '&#216;',
-	"\xD9" => '&#217;',
-	"\xDA" => '&#218;',
-	"\xDB" => '&#219;',
-	"\xDC" => '&#220;',
-	"\xDD" => '&#304;',
-	"\xDE" => '&#350;',
-	"\xDF" => '&#223;',
-	"\xE0" => '&#224;',
-	"\xE1" => '&#225;',
-	"\xE2" => '&#226;',
-	"\xE3" => '&#227;',
-	"\xE4" => '&#228;',
-	"\xE5" => '&#229;',
-	"\xE6" => '&#230;',
-	"\xE7" => '&#231;',
-	"\xE8" => '&#232;',
-	"\xE9" => '&#233;',
-	"\xEA" => '&#234;',
-	"\xEB" => '&#235;',
-	"\xEC" => '&#236;',
-	"\xED" => '&#237;',
-	"\xEE" => '&#238;',
-	"\xEF" => '&#239;',
-	"\xF0" => '&#287;',
-	"\xF1" => '&#241;',
-	"\xF2" => '&#242;',
-	"\xF3" => '&#243;',
-	"\xF4" => '&#244;',
-	"\xF5" => '&#245;',
-	"\xF6" => '&#246;',
-	"\xF7" => '&#247;',
-	"\xF8" => '&#248;',
-	"\xF9" => '&#249;',
-	"\xFA" => '&#250;',
-	"\xFB" => '&#251;',
-	"\xFC" => '&#252;',
-	"\xFD" => '&#305;',
-	"\xFE" => '&#351;',
-	"\xFF" => '&#255;'
+       "\xA0" => '&#160;',
+       "\xA1" => '&#161;',
+       "\xA2" => '&#162;',
+       "\xA3" => '&#163;',
+       "\xA4" => '&#164;',
+       "\xA5" => '&#165;',
+       "\xA6" => '&#166;',
+       "\xA7" => '&#167;',
+       "\xA8" => '&#168;',
+       "\xA9" => '&#169;',
+       "\xAA" => '&#170;',
+       "\xAB" => '&#171;',
+       "\xAC" => '&#172;',
+       "\xAD" => '&#173;',
+       "\xAE" => '&#174;',
+       "\xAF" => '&#175;',
+       "\xB0" => '&#176;',
+       "\xB1" => '&#177;',
+       "\xB2" => '&#178;',
+       "\xB3" => '&#179;',
+       "\xB4" => '&#180;',
+       "\xB5" => '&#181;',
+       "\xB6" => '&#182;',
+       "\xB7" => '&#183;',
+       "\xB8" => '&#184;',
+       "\xB9" => '&#185;',
+       "\xBA" => '&#186;',
+       "\xBB" => '&#187;',
+       "\xBC" => '&#188;',
+       "\xBD" => '&#189;',
+       "\xBE" => '&#190;',
+       "\xBF" => '&#191;',
+       "\xC0" => '&#192;',
+       "\xC1" => '&#193;',
+       "\xC2" => '&#194;',
+       "\xC3" => '&#195;',
+       "\xC4" => '&#196;',
+       "\xC5" => '&#197;',
+       "\xC6" => '&#198;',
+       "\xC7" => '&#199;',
+       "\xC8" => '&#200;',
+       "\xC9" => '&#201;',
+       "\xCA" => '&#202;',
+       "\xCB" => '&#203;',
+       "\xCC" => '&#204;',
+       "\xCD" => '&#205;',
+       "\xCE" => '&#206;',
+       "\xCF" => '&#207;',
+       "\xD0" => '&#286;',
+       "\xD1" => '&#209;',
+       "\xD2" => '&#210;',
+       "\xD3" => '&#211;',
+       "\xD4" => '&#212;',
+       "\xD5" => '&#213;',
+       "\xD6" => '&#214;',
+       "\xD7" => '&#215;',
+       "\xD8" => '&#216;',
+       "\xD9" => '&#217;',
+       "\xDA" => '&#218;',
+       "\xDB" => '&#219;',
+       "\xDC" => '&#220;',
+       "\xDD" => '&#304;',
+       "\xDE" => '&#350;',
+       "\xDF" => '&#223;',
+       "\xE0" => '&#224;',
+       "\xE1" => '&#225;',
+       "\xE2" => '&#226;',
+       "\xE3" => '&#227;',
+       "\xE4" => '&#228;',
+       "\xE5" => '&#229;',
+       "\xE6" => '&#230;',
+       "\xE7" => '&#231;',
+       "\xE8" => '&#232;',
+       "\xE9" => '&#233;',
+       "\xEA" => '&#234;',
+       "\xEB" => '&#235;',
+       "\xEC" => '&#236;',
+       "\xED" => '&#237;',
+       "\xEE" => '&#238;',
+       "\xEF" => '&#239;',
+       "\xF0" => '&#287;',
+       "\xF1" => '&#241;',
+       "\xF2" => '&#242;',
+       "\xF3" => '&#243;',
+       "\xF4" => '&#244;',
+       "\xF5" => '&#245;',
+       "\xF6" => '&#246;',
+       "\xF7" => '&#247;',
+       "\xF8" => '&#248;',
+       "\xF9" => '&#249;',
+       "\xFA" => '&#250;',
+       "\xFB" => '&#251;',
+       "\xFC" => '&#252;',
+       "\xFD" => '&#305;',
+       "\xFE" => '&#351;',
+       "\xFF" => '&#255;'
     );
     );
 
 
     $string = str_replace(array_keys($iso8859_9), array_values($iso8859_9), $string);
     $string = str_replace(array_keys($iso8859_9), array_values($iso8859_9), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 99 - 101
functions/decode/iso_ir_111.php

@@ -55,113 +55,111 @@ function charset_decode_iso_ir_111 ($string) {
     if (strtolower($default_charset) == 'iso-ir-111')
     if (strtolower($default_charset) == 'iso-ir-111')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in ISO-IR-111 */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'iso-ir-111'))
         return $string;
         return $string;
 
 
     $iso_ir_111 = array(
     $iso_ir_111 = array(
-	"\xA0" => '&#160;',
-	"\xA1" => '&#1106;',
-	"\xA2" => '&#1107;',
-	"\xA3" => '&#1105;',
-	"\xA4" => '&#1108;',
-	"\xA5" => '&#1109;',
-	"\xA6" => '&#1110;',
-	"\xA7" => '&#1111;',
-	"\xA8" => '&#1112;',
-	"\xA9" => '&#1113;',
-	"\xAA" => '&#1114;',
-	"\xAB" => '&#1115;',
-	"\xAC" => '&#1116;',
-	"\xAD" => '&#173;',
-	"\xAE" => '&#1118;',
-	"\xAF" => '&#1119;',
-	"\xB0" => '&#8470;',
-	"\xB1" => '&#1026;',
-	"\xB2" => '&#1027;',
-	"\xB3" => '&#1025;',
-	"\xB4" => '&#1028;',
-	"\xB5" => '&#1029;',
-	"\xB6" => '&#1030;',
-	"\xB7" => '&#1031;',
-	"\xB8" => '&#1032;',
-	"\xB9" => '&#1033;',
-	"\xBA" => '&#1034;',
-	"\xBB" => '&#1035;',
-	"\xBC" => '&#1036;',
-	"\xBD" => '&#164;',
-	"\xBE" => '&#1038;',
-	"\xBF" => '&#1039;',
-	"\xC0" => '&#1102;',
-	"\xC1" => '&#1072;',
-	"\xC2" => '&#1073;',
-	"\xC3" => '&#1094;',
-	"\xC4" => '&#1076;',
-	"\xC5" => '&#1077;',
-	"\xC6" => '&#1092;',
-	"\xC7" => '&#1075;',
-	"\xC8" => '&#1093;',
-	"\xC9" => '&#1080;',
-	"\xCA" => '&#1081;',
-	"\xCB" => '&#1082;',
-	"\xCC" => '&#1083;',
-	"\xCD" => '&#1084;',
-	"\xCE" => '&#1085;',
-	"\xCF" => '&#1086;',
-	"\xD0" => '&#1087;',
-	"\xD1" => '&#1103;',
-	"\xD2" => '&#1088;',
-	"\xD3" => '&#1089;',
-	"\xD4" => '&#1090;',
-	"\xD5" => '&#1091;',
-	"\xD6" => '&#1078;',
-	"\xD7" => '&#1074;',
-	"\xD8" => '&#1100;',
-	"\xD9" => '&#1099;',
-	"\xDA" => '&#1079;',
-	"\xDB" => '&#1096;',
-	"\xDC" => '&#1101;',
-	"\xDD" => '&#1097;',
-	"\xDE" => '&#1095;',
-	"\xDF" => '&#1098;',
-	"\xE0" => '&#1070;',
-	"\xE1" => '&#1040;',
-	"\xE2" => '&#1041;',
-	"\xE3" => '&#1062;',
-	"\xE4" => '&#1044;',
-	"\xE5" => '&#1045;',
-	"\xE6" => '&#1060;',
-	"\xE7" => '&#1043;',
-	"\xE8" => '&#1061;',
-	"\xE9" => '&#1048;',
-	"\xEA" => '&#1049;',
-	"\xEB" => '&#1050;',
-	"\xEC" => '&#1051;',
-	"\xED" => '&#1052;',
-	"\xEE" => '&#1053;',
-	"\xEF" => '&#1054;',
-	"\xF0" => '&#1055;',
-	"\xF1" => '&#1071;',
-	"\xF2" => '&#1056;',
-	"\xF3" => '&#1057;',
-	"\xF4" => '&#1058;',
-	"\xF5" => '&#1059;',
-	"\xF6" => '&#1046;',
-	"\xF7" => '&#1042;',
-	"\xF8" => '&#1068;',
-	"\xF9" => '&#1067;',
-	"\xFA" => '&#1047;',
-	"\xFB" => '&#1064;',
-	"\xFC" => '&#1069;',
-	"\xFD" => '&#1065;',
-	"\xFE" => '&#1063;',
-	"\xFF" => '&#1066;'
+        "\xA0" => '&#160;',
+        "\xA1" => '&#1106;',
+        "\xA2" => '&#1107;',
+        "\xA3" => '&#1105;',
+        "\xA4" => '&#1108;',
+        "\xA5" => '&#1109;',
+        "\xA6" => '&#1110;',
+        "\xA7" => '&#1111;',
+        "\xA8" => '&#1112;',
+        "\xA9" => '&#1113;',
+        "\xAA" => '&#1114;',
+        "\xAB" => '&#1115;',
+        "\xAC" => '&#1116;',
+        "\xAD" => '&#173;',
+        "\xAE" => '&#1118;',
+        "\xAF" => '&#1119;',
+        "\xB0" => '&#8470;',
+        "\xB1" => '&#1026;',
+        "\xB2" => '&#1027;',
+        "\xB3" => '&#1025;',
+        "\xB4" => '&#1028;',
+        "\xB5" => '&#1029;',
+        "\xB6" => '&#1030;',
+        "\xB7" => '&#1031;',
+        "\xB8" => '&#1032;',
+        "\xB9" => '&#1033;',
+        "\xBA" => '&#1034;',
+        "\xBB" => '&#1035;',
+        "\xBC" => '&#1036;',
+        "\xBD" => '&#164;',
+        "\xBE" => '&#1038;',
+        "\xBF" => '&#1039;',
+        "\xC0" => '&#1102;',
+        "\xC1" => '&#1072;',
+        "\xC2" => '&#1073;',
+        "\xC3" => '&#1094;',
+        "\xC4" => '&#1076;',
+        "\xC5" => '&#1077;',
+        "\xC6" => '&#1092;',
+        "\xC7" => '&#1075;',
+        "\xC8" => '&#1093;',
+        "\xC9" => '&#1080;',
+        "\xCA" => '&#1081;',
+        "\xCB" => '&#1082;',
+        "\xCC" => '&#1083;',
+        "\xCD" => '&#1084;',
+        "\xCE" => '&#1085;',
+        "\xCF" => '&#1086;',
+        "\xD0" => '&#1087;',
+        "\xD1" => '&#1103;',
+        "\xD2" => '&#1088;',
+        "\xD3" => '&#1089;',
+        "\xD4" => '&#1090;',
+        "\xD5" => '&#1091;',
+        "\xD6" => '&#1078;',
+        "\xD7" => '&#1074;',
+        "\xD8" => '&#1100;',
+        "\xD9" => '&#1099;',
+        "\xDA" => '&#1079;',
+        "\xDB" => '&#1096;',
+        "\xDC" => '&#1101;',
+        "\xDD" => '&#1097;',
+        "\xDE" => '&#1095;',
+        "\xDF" => '&#1098;',
+        "\xE0" => '&#1070;',
+        "\xE1" => '&#1040;',
+        "\xE2" => '&#1041;',
+        "\xE3" => '&#1062;',
+        "\xE4" => '&#1044;',
+        "\xE5" => '&#1045;',
+        "\xE6" => '&#1060;',
+        "\xE7" => '&#1043;',
+        "\xE8" => '&#1061;',
+        "\xE9" => '&#1048;',
+        "\xEA" => '&#1049;',
+        "\xEB" => '&#1050;',
+        "\xEC" => '&#1051;',
+        "\xED" => '&#1052;',
+        "\xEE" => '&#1053;',
+        "\xEF" => '&#1054;',
+        "\xF0" => '&#1055;',
+        "\xF1" => '&#1071;',
+        "\xF2" => '&#1056;',
+        "\xF3" => '&#1057;',
+        "\xF4" => '&#1058;',
+        "\xF5" => '&#1059;',
+        "\xF6" => '&#1046;',
+        "\xF7" => '&#1042;',
+        "\xF8" => '&#1068;',
+        "\xF9" => '&#1067;',
+        "\xFA" => '&#1047;',
+        "\xFB" => '&#1064;',
+        "\xFC" => '&#1069;',
+        "\xFD" => '&#1065;',
+        "\xFE" => '&#1063;',
+        "\xFF" => '&#1066;'
     );
     );
 
 
     $string = str_replace(array_keys($iso_ir_111), array_values($iso_ir_111), $string);
     $string = str_replace(array_keys($iso_ir_111), array_values($iso_ir_111), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 131 - 133
functions/decode/koi8_r.php

@@ -50,145 +50,143 @@ function charset_decode_koi8_r ($string) {
     if (strtolower($default_charset) == 'koi8-r')
     if (strtolower($default_charset) == 'koi8-r')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'koi8-r'))
         return $string;
         return $string;
 
 
     $koi8r = array(
     $koi8r = array(
-	"\x80" => '&#9472;',
-	"\x81" => '&#9474;',
-	"\x82" => '&#9484;',
-	"\x83" => '&#9488;',
-	"\x84" => '&#9492;',
-	"\x85" => '&#9496;',
-	"\x86" => '&#9500;',
-	"\x87" => '&#9508;',
-	"\x88" => '&#9516;',
-	"\x89" => '&#9524;',
-	"\x8A" => '&#9532;',
-	"\x8B" => '&#9600;',
-	"\x8C" => '&#9604;',
-	"\x8D" => '&#9608;',
-	"\x8E" => '&#9612;',
-	"\x8F" => '&#9616;',
-	"\x90" => '&#9617;',
-	"\x91" => '&#9618;',
-	"\x92" => '&#9619;',
-	"\x93" => '&#8992;',
-	"\x94" => '&#9632;',
-	"\x95" => '&#8729;',
-	"\x96" => '&#8730;',
-	"\x97" => '&#8776;',
-	"\x98" => '&#8804;',
-	"\x99" => '&#8805;',
-	"\x9A" => '&#160;',
-	"\x9B" => '&#8993;',
-	"\x9C" => '&#176;',
-	"\x9D" => '&#178;',
-	"\x9E" => '&#183;',
-	"\x9F" => '&#247;',
-	"\xA0" => '&#9552;',
-	"\xA1" => '&#9553;',
-	"\xA2" => '&#9554;',
-	"\xA3" => '&#1105;',
-	"\xA4" => '&#9555;',
-	"\xA5" => '&#9556;',
-	"\xA6" => '&#9557;',
-	"\xA7" => '&#9558;',
-	"\xA8" => '&#9559;',
-	"\xA9" => '&#9560;',
-	"\xAA" => '&#9561;',
-	"\xAB" => '&#9562;',
-	"\xAC" => '&#9563;',
-	"\xAD" => '&#9564;',
-	"\xAE" => '&#9565;',
-	"\xAF" => '&#9566;',
-	"\xB0" => '&#9567;',
-	"\xB1" => '&#9568;',
-	"\xB2" => '&#9569;',
-	"\xB3" => '&#1025;',
-	"\xB4" => '&#9570;',
-	"\xB5" => '&#9571;',
-	"\xB6" => '&#9572;',
-	"\xB7" => '&#9573;',
-	"\xB8" => '&#9574;',
-	"\xB9" => '&#9575;',
-	"\xBA" => '&#9576;',
-	"\xBB" => '&#9577;',
-	"\xBC" => '&#9578;',
-	"\xBD" => '&#9579;',
-	"\xBE" => '&#9580;',
-	"\xBF" => '&#169;',
-	"\xC0" => '&#1102;',
-	"\xC1" => '&#1072;',
-	"\xC2" => '&#1073;',
-	"\xC3" => '&#1094;',
-	"\xC4" => '&#1076;',
-	"\xC5" => '&#1077;',
-	"\xC6" => '&#1092;',
-	"\xC7" => '&#1075;',
-	"\xC8" => '&#1093;',
-	"\xC9" => '&#1080;',
-	"\xCA" => '&#1081;',
-	"\xCB" => '&#1082;',
-	"\xCC" => '&#1083;',
-	"\xCD" => '&#1084;',
-	"\xCE" => '&#1085;',
-	"\xCF" => '&#1086;',
-	"\xD0" => '&#1087;',
-	"\xD1" => '&#1103;',
-	"\xD2" => '&#1088;',
-	"\xD3" => '&#1089;',
-	"\xD4" => '&#1090;',
-	"\xD5" => '&#1091;',
-	"\xD6" => '&#1078;',
-	"\xD7" => '&#1074;',
-	"\xD8" => '&#1100;',
-	"\xD9" => '&#1099;',
-	"\xDA" => '&#1079;',
-	"\xDB" => '&#1096;',
-	"\xDC" => '&#1101;',
-	"\xDD" => '&#1097;',
-	"\xDE" => '&#1095;',
-	"\xDF" => '&#1098;',
-	"\xE0" => '&#1070;',
-	"\xE1" => '&#1040;',
-	"\xE2" => '&#1041;',
-	"\xE3" => '&#1062;',
-	"\xE4" => '&#1044;',
-	"\xE5" => '&#1045;',
-	"\xE6" => '&#1060;',
-	"\xE7" => '&#1043;',
-	"\xE8" => '&#1061;',
-	"\xE9" => '&#1048;',
-	"\xEA" => '&#1049;',
-	"\xEB" => '&#1050;',
-	"\xEC" => '&#1051;',
-	"\xED" => '&#1052;',
-	"\xEE" => '&#1053;',
-	"\xEF" => '&#1054;',
-	"\xF0" => '&#1055;',
-	"\xF1" => '&#1071;',
-	"\xF2" => '&#1056;',
-	"\xF3" => '&#1057;',
-	"\xF4" => '&#1058;',
-	"\xF5" => '&#1059;',
-	"\xF6" => '&#1046;',
-	"\xF7" => '&#1042;',
-	"\xF8" => '&#1068;',
-	"\xF9" => '&#1067;',
-	"\xFA" => '&#1047;',
-	"\xFB" => '&#1064;',
-	"\xFC" => '&#1069;',
-	"\xFD" => '&#1065;',
-	"\xFE" => '&#1063;',
-	"\xFF" => '&#1066;'
+        "\x80" => '&#9472;',
+        "\x81" => '&#9474;',
+        "\x82" => '&#9484;',
+        "\x83" => '&#9488;',
+        "\x84" => '&#9492;',
+        "\x85" => '&#9496;',
+        "\x86" => '&#9500;',
+        "\x87" => '&#9508;',
+        "\x88" => '&#9516;',
+        "\x89" => '&#9524;',
+        "\x8A" => '&#9532;',
+        "\x8B" => '&#9600;',
+        "\x8C" => '&#9604;',
+        "\x8D" => '&#9608;',
+        "\x8E" => '&#9612;',
+        "\x8F" => '&#9616;',
+        "\x90" => '&#9617;',
+        "\x91" => '&#9618;',
+        "\x92" => '&#9619;',
+        "\x93" => '&#8992;',
+        "\x94" => '&#9632;',
+        "\x95" => '&#8729;',
+        "\x96" => '&#8730;',
+        "\x97" => '&#8776;',
+        "\x98" => '&#8804;',
+        "\x99" => '&#8805;',
+        "\x9A" => '&#160;',
+        "\x9B" => '&#8993;',
+        "\x9C" => '&#176;',
+        "\x9D" => '&#178;',
+        "\x9E" => '&#183;',
+        "\x9F" => '&#247;',
+        "\xA0" => '&#9552;',
+        "\xA1" => '&#9553;',
+        "\xA2" => '&#9554;',
+        "\xA3" => '&#1105;',
+        "\xA4" => '&#9555;',
+        "\xA5" => '&#9556;',
+        "\xA6" => '&#9557;',
+        "\xA7" => '&#9558;',
+        "\xA8" => '&#9559;',
+        "\xA9" => '&#9560;',
+        "\xAA" => '&#9561;',
+        "\xAB" => '&#9562;',
+        "\xAC" => '&#9563;',
+        "\xAD" => '&#9564;',
+        "\xAE" => '&#9565;',
+        "\xAF" => '&#9566;',
+        "\xB0" => '&#9567;',
+        "\xB1" => '&#9568;',
+        "\xB2" => '&#9569;',
+        "\xB3" => '&#1025;',
+        "\xB4" => '&#9570;',
+        "\xB5" => '&#9571;',
+        "\xB6" => '&#9572;',
+        "\xB7" => '&#9573;',
+        "\xB8" => '&#9574;',
+        "\xB9" => '&#9575;',
+        "\xBA" => '&#9576;',
+        "\xBB" => '&#9577;',
+        "\xBC" => '&#9578;',
+        "\xBD" => '&#9579;',
+        "\xBE" => '&#9580;',
+        "\xBF" => '&#169;',
+        "\xC0" => '&#1102;',
+        "\xC1" => '&#1072;',
+        "\xC2" => '&#1073;',
+        "\xC3" => '&#1094;',
+        "\xC4" => '&#1076;',
+        "\xC5" => '&#1077;',
+        "\xC6" => '&#1092;',
+        "\xC7" => '&#1075;',
+        "\xC8" => '&#1093;',
+        "\xC9" => '&#1080;',
+        "\xCA" => '&#1081;',
+        "\xCB" => '&#1082;',
+        "\xCC" => '&#1083;',
+        "\xCD" => '&#1084;',
+        "\xCE" => '&#1085;',
+        "\xCF" => '&#1086;',
+        "\xD0" => '&#1087;',
+        "\xD1" => '&#1103;',
+        "\xD2" => '&#1088;',
+        "\xD3" => '&#1089;',
+        "\xD4" => '&#1090;',
+        "\xD5" => '&#1091;',
+        "\xD6" => '&#1078;',
+        "\xD7" => '&#1074;',
+        "\xD8" => '&#1100;',
+        "\xD9" => '&#1099;',
+        "\xDA" => '&#1079;',
+        "\xDB" => '&#1096;',
+        "\xDC" => '&#1101;',
+        "\xDD" => '&#1097;',
+        "\xDE" => '&#1095;',
+        "\xDF" => '&#1098;',
+        "\xE0" => '&#1070;',
+        "\xE1" => '&#1040;',
+        "\xE2" => '&#1041;',
+        "\xE3" => '&#1062;',
+        "\xE4" => '&#1044;',
+        "\xE5" => '&#1045;',
+        "\xE6" => '&#1060;',
+        "\xE7" => '&#1043;',
+        "\xE8" => '&#1061;',
+        "\xE9" => '&#1048;',
+        "\xEA" => '&#1049;',
+        "\xEB" => '&#1050;',
+        "\xEC" => '&#1051;',
+        "\xED" => '&#1052;',
+        "\xEE" => '&#1053;',
+        "\xEF" => '&#1054;',
+        "\xF0" => '&#1055;',
+        "\xF1" => '&#1071;',
+        "\xF2" => '&#1056;',
+        "\xF3" => '&#1057;',
+        "\xF4" => '&#1058;',
+        "\xF5" => '&#1059;',
+        "\xF6" => '&#1046;',
+        "\xF7" => '&#1042;',
+        "\xF8" => '&#1068;',
+        "\xF9" => '&#1067;',
+        "\xFA" => '&#1047;',
+        "\xFB" => '&#1064;',
+        "\xFC" => '&#1069;',
+        "\xFD" => '&#1065;',
+        "\xFE" => '&#1063;',
+        "\xFF" => '&#1066;'
     );
     );
 
 
     $string = str_replace(array_keys($koi8r), array_values($koi8r), $string);
     $string = str_replace(array_keys($koi8r), array_values($koi8r), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 131 - 133
functions/decode/koi8_u.php

@@ -54,145 +54,143 @@ function charset_decode_koi8_u ($string) {
     if (strtolower($default_charset) == 'koi8-u')
     if (strtolower($default_charset) == 'koi8-u')
         return $string;
         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) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'koi8-u'))
         return $string;
         return $string;
 
 
     $koi8u = array(
     $koi8u = array(
-	"\x80" => '&#9472;',
-	"\x81" => '&#9474;',
-	"\x82" => '&#9484;',
-	"\x83" => '&#9488;',
-	"\x84" => '&#9492;',
-	"\x85" => '&#9496;',
-	"\x86" => '&#9500;',
-	"\x87" => '&#9508;',
-	"\x88" => '&#9516;',
-	"\x89" => '&#9524;',
-	"\x8A" => '&#9532;',
-	"\x8B" => '&#9600;',
-	"\x8C" => '&#9604;',
-	"\x8D" => '&#9608;',
-	"\x8E" => '&#9612;',
-	"\x8F" => '&#9616;',
-	"\x90" => '&#9617;',
-	"\x91" => '&#9618;',
-	"\x92" => '&#9619;',
-	"\x93" => '&#8992;',
-	"\x94" => '&#9632;',
-	"\x95" => '&#8729;',
-	"\x96" => '&#8730;',
-	"\x97" => '&#8776;',
-	"\x98" => '&#8804;',
-	"\x99" => '&#8805;',
-	"\x9A" => '&#160;',
-	"\x9B" => '&#8993;',
-	"\x9C" => '&#176;',
-	"\x9D" => '&#178;',
-	"\x9E" => '&#183;',
-	"\x9F" => '&#247;',
-	"\xA0" => '&#9552;',
-	"\xA1" => '&#9553;',
-	"\xA2" => '&#9554;',
-	"\xA3" => '&#1105;',
-	"\xA4" => '&#1108;',
-	"\xA5" => '&#9556;',
-	"\xA6" => '&#1110;',
-	"\xA7" => '&#1111;',
-	"\xA8" => '&#9559;',
-	"\xA9" => '&#9560;',
-	"\xAA" => '&#9561;',
-	"\xAB" => '&#9562;',
-	"\xAC" => '&#9563;',
-	"\xAD" => '&#1169;',
-	"\xAE" => '&#9565;',
-	"\xAF" => '&#9566;',
-	"\xB0" => '&#9567;',
-	"\xB1" => '&#9568;',
-	"\xB2" => '&#9569;',
-	"\xB3" => '&#1025;',
-	"\xB4" => '&#1027;',
-	"\xB5" => '&#9571;',
-	"\xB6" => '&#1030;',
-	"\xB7" => '&#1031;',
-	"\xB8" => '&#9574;',
-	"\xB9" => '&#9575;',
-	"\xBA" => '&#9576;',
-	"\xBB" => '&#9577;',
-	"\xBC" => '&#9578;',
-	"\xBD" => '&#1168;',
-	"\xBE" => '&#9580;',
-	"\xBF" => '&#169;',
-	"\xC0" => '&#1102;',
-	"\xC1" => '&#1072;',
-	"\xC2" => '&#1073;',
-	"\xC3" => '&#1094;',
-	"\xC4" => '&#1076;',
-	"\xC5" => '&#1077;',
-	"\xC6" => '&#1092;',
-	"\xC7" => '&#1075;',
-	"\xC8" => '&#1093;',
-	"\xC9" => '&#1080;',
-	"\xCA" => '&#1081;',
-	"\xCB" => '&#1082;',
-	"\xCC" => '&#1083;',
-	"\xCD" => '&#1084;',
-	"\xCE" => '&#1085;',
-	"\xCF" => '&#1086;',
-	"\xD0" => '&#1087;',
-	"\xD1" => '&#1103;',
-	"\xD2" => '&#1088;',
-	"\xD3" => '&#1089;',
-	"\xD4" => '&#1090;',
-	"\xD5" => '&#1091;',
-	"\xD6" => '&#1078;',
-	"\xD7" => '&#1074;',
-	"\xD8" => '&#1100;',
-	"\xD9" => '&#1099;',
-	"\xDA" => '&#1079;',
-	"\xDB" => '&#1096;',
-	"\xDC" => '&#1101;',
-	"\xDD" => '&#1097;',
-	"\xDE" => '&#1095;',
-	"\xDF" => '&#1098;',
-	"\xE0" => '&#1070;',
-	"\xE1" => '&#1040;',
-	"\xE2" => '&#1041;',
-	"\xE3" => '&#1062;',
-	"\xE4" => '&#1044;',
-	"\xE5" => '&#1045;',
-	"\xE6" => '&#1060;',
-	"\xE7" => '&#1043;',
-	"\xE8" => '&#1061;',
-	"\xE9" => '&#1048;',
-	"\xEA" => '&#1049;',
-	"\xEB" => '&#1050;',
-	"\xEC" => '&#1051;',
-	"\xED" => '&#1052;',
-	"\xEE" => '&#1053;',
-	"\xEF" => '&#1054;',
-	"\xF0" => '&#1055;',
-	"\xF1" => '&#1071;',
-	"\xF2" => '&#1056;',
-	"\xF3" => '&#1057;',
-	"\xF4" => '&#1058;',
-	"\xF5" => '&#1059;',
-	"\xF6" => '&#1046;',
-	"\xF7" => '&#1042;',
-	"\xF8" => '&#1068;',
-	"\xF9" => '&#1067;',
-	"\xFA" => '&#1047;',
-	"\xFB" => '&#1064;',
-	"\xFC" => '&#1069;',
-	"\xFD" => '&#1065;',
-	"\xFE" => '&#1063;',
-	"\xFF" => '&#1066;'
+        "\x80" => '&#9472;',
+        "\x81" => '&#9474;',
+        "\x82" => '&#9484;',
+        "\x83" => '&#9488;',
+        "\x84" => '&#9492;',
+        "\x85" => '&#9496;',
+        "\x86" => '&#9500;',
+        "\x87" => '&#9508;',
+        "\x88" => '&#9516;',
+        "\x89" => '&#9524;',
+        "\x8A" => '&#9532;',
+        "\x8B" => '&#9600;',
+        "\x8C" => '&#9604;',
+        "\x8D" => '&#9608;',
+        "\x8E" => '&#9612;',
+        "\x8F" => '&#9616;',
+        "\x90" => '&#9617;',
+        "\x91" => '&#9618;',
+        "\x92" => '&#9619;',
+        "\x93" => '&#8992;',
+        "\x94" => '&#9632;',
+        "\x95" => '&#8729;',
+        "\x96" => '&#8730;',
+        "\x97" => '&#8776;',
+        "\x98" => '&#8804;',
+        "\x99" => '&#8805;',
+        "\x9A" => '&#160;',
+        "\x9B" => '&#8993;',
+        "\x9C" => '&#176;',
+        "\x9D" => '&#178;',
+        "\x9E" => '&#183;',
+        "\x9F" => '&#247;',
+        "\xA0" => '&#9552;',
+        "\xA1" => '&#9553;',
+        "\xA2" => '&#9554;',
+        "\xA3" => '&#1105;',
+        "\xA4" => '&#1108;',
+        "\xA5" => '&#9556;',
+        "\xA6" => '&#1110;',
+        "\xA7" => '&#1111;',
+        "\xA8" => '&#9559;',
+        "\xA9" => '&#9560;',
+        "\xAA" => '&#9561;',
+        "\xAB" => '&#9562;',
+        "\xAC" => '&#9563;',
+        "\xAD" => '&#1169;',
+        "\xAE" => '&#9565;',
+        "\xAF" => '&#9566;',
+        "\xB0" => '&#9567;',
+        "\xB1" => '&#9568;',
+        "\xB2" => '&#9569;',
+        "\xB3" => '&#1025;',
+        "\xB4" => '&#1027;',
+        "\xB5" => '&#9571;',
+        "\xB6" => '&#1030;',
+        "\xB7" => '&#1031;',
+        "\xB8" => '&#9574;',
+        "\xB9" => '&#9575;',
+        "\xBA" => '&#9576;',
+        "\xBB" => '&#9577;',
+        "\xBC" => '&#9578;',
+        "\xBD" => '&#1168;',
+        "\xBE" => '&#9580;',
+        "\xBF" => '&#169;',
+        "\xC0" => '&#1102;',
+        "\xC1" => '&#1072;',
+        "\xC2" => '&#1073;',
+        "\xC3" => '&#1094;',
+        "\xC4" => '&#1076;',
+        "\xC5" => '&#1077;',
+        "\xC6" => '&#1092;',
+        "\xC7" => '&#1075;',
+        "\xC8" => '&#1093;',
+        "\xC9" => '&#1080;',
+        "\xCA" => '&#1081;',
+        "\xCB" => '&#1082;',
+        "\xCC" => '&#1083;',
+        "\xCD" => '&#1084;',
+        "\xCE" => '&#1085;',
+        "\xCF" => '&#1086;',
+        "\xD0" => '&#1087;',
+        "\xD1" => '&#1103;',
+        "\xD2" => '&#1088;',
+        "\xD3" => '&#1089;',
+        "\xD4" => '&#1090;',
+        "\xD5" => '&#1091;',
+        "\xD6" => '&#1078;',
+        "\xD7" => '&#1074;',
+        "\xD8" => '&#1100;',
+        "\xD9" => '&#1099;',
+        "\xDA" => '&#1079;',
+        "\xDB" => '&#1096;',
+        "\xDC" => '&#1101;',
+        "\xDD" => '&#1097;',
+        "\xDE" => '&#1095;',
+        "\xDF" => '&#1098;',
+        "\xE0" => '&#1070;',
+        "\xE1" => '&#1040;',
+        "\xE2" => '&#1041;',
+        "\xE3" => '&#1062;',
+        "\xE4" => '&#1044;',
+        "\xE5" => '&#1045;',
+        "\xE6" => '&#1060;',
+        "\xE7" => '&#1043;',
+        "\xE8" => '&#1061;',
+        "\xE9" => '&#1048;',
+        "\xEA" => '&#1049;',
+        "\xEB" => '&#1050;',
+        "\xEC" => '&#1051;',
+        "\xED" => '&#1052;',
+        "\xEE" => '&#1053;',
+        "\xEF" => '&#1054;',
+        "\xF0" => '&#1055;',
+        "\xF1" => '&#1071;',
+        "\xF2" => '&#1056;',
+        "\xF3" => '&#1057;',
+        "\xF4" => '&#1058;',
+        "\xF5" => '&#1059;',
+        "\xF6" => '&#1046;',
+        "\xF7" => '&#1042;',
+        "\xF8" => '&#1068;',
+        "\xF9" => '&#1067;',
+        "\xFA" => '&#1047;',
+        "\xFB" => '&#1064;',
+        "\xFC" => '&#1069;',
+        "\xFD" => '&#1065;',
+        "\xFE" => '&#1063;',
+        "\xFF" => '&#1066;'
     );
     );
 
 
     $string = str_replace(array_keys($koi8u), array_values($koi8u), $string);
     $string = str_replace(array_keys($koi8u), array_values($koi8u), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 100 - 102
functions/decode/tis_620.php

@@ -49,113 +49,111 @@ function charset_decode_tis_620 ($string) {
     if (strtolower($default_charset) == 'tis-620')
     if (strtolower($default_charset) == 'tis-620')
         return $string;
         return $string;
 
 
-    /* Only do the slow convert if there are 8-bit characters */
-    /* there is no 0x80-0x9F letters in TIS620 */
-    if ( ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'tis-620'))
         return $string;
         return $string;
 
 
     $tis620 = array(
     $tis620 = array(
-		"\xA0" => '&#65535;',
-		"\xA1" => '&#3585;',
-		"\xA2" => '&#3586;',
-		"\xA3" => '&#3587;',
-		"\xA4" => '&#3588;',
-		"\xA5" => '&#3589;',
-		"\xA6" => '&#3590;',
-		"\xA7" => '&#3591;',
-		"\xA8" => '&#3592;',
-		"\xA9" => '&#3593;',
-		"\xAA" => '&#3594;',
-		"\xAB" => '&#3595;',
-		"\xAC" => '&#3596;',
-		"\xAD" => '&#3597;',
-		"\xAE" => '&#3598;',
-		"\xAF" => '&#3599;',
-		"\xB0" => '&#3600;',
-		"\xB1" => '&#3601;',
-		"\xB2" => '&#3602;',
-		"\xB3" => '&#3603;',
-		"\xB4" => '&#3604;',
-		"\xB5" => '&#3605;',
-		"\xB6" => '&#3606;',
-		"\xB7" => '&#3607;',
-		"\xB8" => '&#3608;',
-		"\xB9" => '&#3609;',
-		"\xBA" => '&#3610;',
-		"\xBB" => '&#3611;',
-		"\xBC" => '&#3612;',
-		"\xBD" => '&#3613;',
-		"\xBE" => '&#3614;',
-		"\xBF" => '&#3615;',
-		"\xC0" => '&#3616;',
-		"\xC1" => '&#3617;',
-		"\xC2" => '&#3618;',
-		"\xC3" => '&#3619;',
-		"\xC4" => '&#3620;',
-		"\xC5" => '&#3621;',
-		"\xC6" => '&#3622;',
-		"\xC7" => '&#3623;',
-		"\xC8" => '&#3624;',
-		"\xC9" => '&#3625;',
-		"\xCA" => '&#3626;',
-		"\xCB" => '&#3627;',
-		"\xCC" => '&#3628;',
-		"\xCD" => '&#3629;',
-		"\xCE" => '&#3630;',
-		"\xCF" => '&#3631;',
-		"\xD0" => '&#3632;',
-		"\xD1" => '&#3633;',
-		"\xD2" => '&#3634;',
-		"\xD3" => '&#3635;',
-		"\xD4" => '&#3636;',
-		"\xD5" => '&#3637;',
-		"\xD6" => '&#3638;',
-		"\xD7" => '&#3639;',
-		"\xD8" => '&#3640;',
-		"\xD9" => '&#3641;',
-		"\xDA" => '&#3642;',
-		"\xDB" => '&#65535;',
-		"\xDC" => '&#65535;',
-		"\xDD" => '&#65535;',
-		"\xDE" => '&#65535;',
-		"\xDF" => '&#3647;',
-		"\xE0" => '&#3648;',
-		"\xE1" => '&#3649;',
-		"\xE2" => '&#3650;',
-		"\xE3" => '&#3651;',
-		"\xE4" => '&#3652;',
-		"\xE5" => '&#3653;',
-		"\xE6" => '&#3654;',
-		"\xE7" => '&#3655;',
-		"\xE8" => '&#3656;',
-		"\xE9" => '&#3657;',
-		"\xEA" => '&#3658;',
-		"\xEB" => '&#3659;',
-		"\xEC" => '&#3660;',
-		"\xED" => '&#3661;',
-		"\xEE" => '&#3662;',
-		"\xEF" => '&#3663;',
-		"\xF0" => '&#3664;',
-		"\xF1" => '&#3665;',
-		"\xF2" => '&#3666;',
-		"\xF3" => '&#3667;',
-		"\xF4" => '&#3668;',
-		"\xF5" => '&#3669;',
-		"\xF6" => '&#3670;',
-		"\xF7" => '&#3671;',
-		"\xF8" => '&#3672;',
-		"\xF9" => '&#3673;',
-		"\xFA" => '&#3674;',
-		"\xFB" => '&#3675;',
-		"\xFC" => '&#65535;',
-		"\xFD" => '&#65535;',
-		"\xFE" => '&#65535;',
-		"\xFF" => '&#65535;'
-		);
+        "\xA0" => '&#65535;',
+        "\xA1" => '&#3585;',
+        "\xA2" => '&#3586;',
+        "\xA3" => '&#3587;',
+        "\xA4" => '&#3588;',
+        "\xA5" => '&#3589;',
+        "\xA6" => '&#3590;',
+        "\xA7" => '&#3591;',
+        "\xA8" => '&#3592;',
+        "\xA9" => '&#3593;',
+        "\xAA" => '&#3594;',
+        "\xAB" => '&#3595;',
+        "\xAC" => '&#3596;',
+        "\xAD" => '&#3597;',
+        "\xAE" => '&#3598;',
+        "\xAF" => '&#3599;',
+        "\xB0" => '&#3600;',
+        "\xB1" => '&#3601;',
+        "\xB2" => '&#3602;',
+        "\xB3" => '&#3603;',
+        "\xB4" => '&#3604;',
+        "\xB5" => '&#3605;',
+        "\xB6" => '&#3606;',
+        "\xB7" => '&#3607;',
+        "\xB8" => '&#3608;',
+        "\xB9" => '&#3609;',
+        "\xBA" => '&#3610;',
+        "\xBB" => '&#3611;',
+        "\xBC" => '&#3612;',
+        "\xBD" => '&#3613;',
+        "\xBE" => '&#3614;',
+        "\xBF" => '&#3615;',
+        "\xC0" => '&#3616;',
+        "\xC1" => '&#3617;',
+        "\xC2" => '&#3618;',
+        "\xC3" => '&#3619;',
+        "\xC4" => '&#3620;',
+        "\xC5" => '&#3621;',
+        "\xC6" => '&#3622;',
+        "\xC7" => '&#3623;',
+        "\xC8" => '&#3624;',
+        "\xC9" => '&#3625;',
+        "\xCA" => '&#3626;',
+        "\xCB" => '&#3627;',
+        "\xCC" => '&#3628;',
+        "\xCD" => '&#3629;',
+        "\xCE" => '&#3630;',
+        "\xCF" => '&#3631;',
+        "\xD0" => '&#3632;',
+        "\xD1" => '&#3633;',
+        "\xD2" => '&#3634;',
+        "\xD3" => '&#3635;',
+        "\xD4" => '&#3636;',
+        "\xD5" => '&#3637;',
+        "\xD6" => '&#3638;',
+        "\xD7" => '&#3639;',
+        "\xD8" => '&#3640;',
+        "\xD9" => '&#3641;',
+        "\xDA" => '&#3642;',
+        "\xDB" => '&#65535;',
+        "\xDC" => '&#65535;',
+        "\xDD" => '&#65535;',
+        "\xDE" => '&#65535;',
+        "\xDF" => '&#3647;',
+        "\xE0" => '&#3648;',
+        "\xE1" => '&#3649;',
+        "\xE2" => '&#3650;',
+        "\xE3" => '&#3651;',
+        "\xE4" => '&#3652;',
+        "\xE5" => '&#3653;',
+        "\xE6" => '&#3654;',
+        "\xE7" => '&#3655;',
+        "\xE8" => '&#3656;',
+        "\xE9" => '&#3657;',
+        "\xEA" => '&#3658;',
+        "\xEB" => '&#3659;',
+        "\xEC" => '&#3660;',
+        "\xED" => '&#3661;',
+        "\xEE" => '&#3662;',
+        "\xEF" => '&#3663;',
+        "\xF0" => '&#3664;',
+        "\xF1" => '&#3665;',
+        "\xF2" => '&#3666;',
+        "\xF3" => '&#3667;',
+        "\xF4" => '&#3668;',
+        "\xF5" => '&#3669;',
+        "\xF6" => '&#3670;',
+        "\xF7" => '&#3671;',
+        "\xF8" => '&#3672;',
+        "\xF9" => '&#3673;',
+        "\xFA" => '&#3674;',
+        "\xFB" => '&#3675;',
+        "\xFC" => '&#65535;',
+        "\xFD" => '&#65535;',
+        "\xFE" => '&#65535;',
+        "\xFF" => '&#65535;'
+        );
 
 
     $string = str_replace(array_keys($tis620), array_values($tis620), $string);
     $string = str_replace(array_keys($tis620), array_values($tis620), $string);
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>

+ 3 - 2
functions/decode/us_ascii.php

@@ -28,7 +28,8 @@ function charset_decode_us_ascii ($string) {
     if (strtolower($default_charset) == 'us-ascii')
     if (strtolower($default_charset) == 'us-ascii')
         return $string;
         return $string;
 
 
-    if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'us-ascii'))
         return $string;
         return $string;
 
 
     $string = preg_replace("/([\201-\237])/e","'?'",$string);
     $string = preg_replace("/([\201-\237])/e","'?'",$string);
@@ -39,4 +40,4 @@ function charset_decode_us_ascii ($string) {
     $string = preg_replace("/([\241-\377])/e","'?'",$string);
     $string = preg_replace("/([\241-\377])/e","'?'",$string);
     return $string;
     return $string;
 }
 }
-?>
+?>

+ 3 - 5
functions/decode/utf_8.php

@@ -32,9 +32,8 @@ function charset_decode_utf_8 ($string) {
     if ($squirrelmail_language == 'ja_JP')
     if ($squirrelmail_language == 'ja_JP')
         return $string;
         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))
+    // don't do decoding when there are no 8bit symbols
+    if (! sq_is8bit($string,'utf-8'))
         return $string;
         return $string;
 
 
     // decode three byte unicode characters
     // decode three byte unicode characters
@@ -49,5 +48,4 @@ function charset_decode_utf_8 ($string) {
 
 
     return $string;
     return $string;
 }
 }
-
-?>
+?>