From:             joao dot rebelo at pchouse dot pt
Operating system: Windows XP SP3
PHP version:      5.2.8
PHP Bug Type:     ICONV related
Bug description:  mb_detect_encoding doesn´t detect 

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 bug report at http://bugs.php.net/?id=47018&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47018&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47018&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47018&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47018&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47018&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47018&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47018&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47018&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47018&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47018&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47018&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47018&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47018&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47018&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47018&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47018&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47018&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47018&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47018&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47018&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47018&r=mysqlcfg

Reply via email to