|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-02-04 22:23 UTC] jani@php.net
[2009-02-12 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
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.