using sq_is8bit function instead of ereg. Code reuse and fixes some problems
[squirrelmail.git] / functions / decode / cp1251.php
index 6ba0ca07c2d21c4c72d17767872b74ecb75ff804..5ac43697b5c35c02224604a24e7fea866204cd82 100644 (file)
@@ -1,9 +1,8 @@
 <?php
-/*
+/**
  * decode/cp1251.php
- * $Id$
  *
- * Copyright (c) 2003 The SquirrelMail Project Team
+ * Copyright (c) 2003-2004 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This file contains cp1251 decoding function that is needed to read
  *   Date:          04/15/98
  *   Contact:       cpxlate@microsoft.com
  *
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage decode
  */
 
+/**
+ * Decode cp1251-encoded string
+ * @param string $string Encoded string
+ * @return string $string Decoded string
+ */
 function charset_decode_cp1251 ($string) {
     global $default_charset;
 
     if (strtolower($default_charset) == 'windows-1251')
         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;
 
     $cp1251 = array(
@@ -168,4 +174,4 @@ function charset_decode_cp1251 ($string) {
     return $string;
 }
 
-?>
\ No newline at end of file
+?>