ID:               47018
 Updated by:       [email protected]
 Reported By:      joao dot rebelo at pchouse dot pt
-Status:           Open
+Status:           Feedback
 Bug Type:         mbstring related
 Operating System: Windows XP SP3
 PHP Version:      5.2.8
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




Previous Comments:
------------------------------------------------------------------------

[2009-01-06 11:13:48] joao dot rebelo at pchouse dot pt

Description:
------------
mb_detect_encoding always detect the input string encode as the first
in the encoding list supplied, in this case because the first in the
list is  UTF-8 always detect as UTF-8, even if the string is  in another
encode, if no encoding list is supplied always detect as ASCII.

Reproduce code:
---------------
    function conv2latin($values2conv){
     $encode = mb_detect_encoding($vl2conv, 'utf-8, ISO-8859-1',
true);
        if(is_array($values2conv)){
            foreach($values2conv as $key2conv=>$vl2conv){
                $encode = mb_detect_encoding($vl2conv);
                if( strtoupper($encode) != "ISO-8859-1"){
                    $vl2conv = iconv($encode, 'ISO-8859-1', $vl2conv);
                }
              $return[$key2conv]=$vl2conv;
            }
        }elseif(!empty($values2conv)){
           $encode = mb_detect_encoding($vl2conv);
           if( strtoupper($encode) != "ISO-8859-1" ){
                    $return = iconv($encode, 'ISO-8859-1',
$values2conv);
                }
        }
        return $return;

return $values2conv;
    }//end function

Expected result:
----------------
The function is pretending to return the string as is if the input
string is in ISO-8859-1 if not is pretending to convert the string from
UTF-8 to ISO-8859-1 and return the converted string.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47018&edit=1

Reply via email to