From: mark at lange dot demon dot co dot uk Operating system: Win32 PHP version: 4.3.2 PHP Bug Type: mbstring related Bug description: mb_convert_encoding weirdness
Description: ------------ A piece of code that was working perfectly correctly with PHP version 4.2.3 is now displaying erroneous characters for PHP 4.3.2. The script in question is a translation form, displaying two languages which may use different charsets. The code determines the appropriate charset to use for the html header from the two languages. If the charsets are the same, no problem. If they are different, it tests whther the mbstring module is enabled, in which case it uses 'UTF-8' for the html header; otherwise it uses the charset for the second language. If mbstring was enabled, then the code uses the mb_convert_encoding function to convert the text strings for display to UTF-8... Reproduce code: --------------- $basecharset = 'ISO-8859-1'; $charset = 'ISO-8859-2'; $convertcharsets = ($basecharset != $charset); if ($convertcharsets) { if (function_exists('mb_convert_encoding')) { formheader('UTF-8'); } else { $convertcharsets = false; formheader($charset); } } else { formheader($basecharset); } echo charsetText('Français',$convertcharset,$basecharset) echo '<br />'; echo charsetText('Polska',$convertcharset,$charset) echo '<br />'; function charsetText($text,$convertcharset,$fromcharset) { $returntext = $text; if ($convertcharset) { $returntext = mb_convert_encoding($returntext,"UTF-8",$fromcharset); } return $returntext; } // function charsetText() Expected result: ---------------- Français Polska Actual result: -------------- Français Polska The first odd character in FranXXais is A with a tilde; the second is the HTML § character -- Edit bug report at http://bugs.php.net/?id=24218&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24218&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24218&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24218&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24218&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24218&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24218&r=support Expected behavior: http://bugs.php.net/fix.php?id=24218&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24218&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24218&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24218&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24218&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24218&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24218&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24218&r=gnused