#43375 [NEW]: utf8_decode

From: Date: Thu, 22 Nov 2007 13:02:32 +0000
Subject: #43375 [NEW]: utf8_decode
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-119954@lists.php.net to get a copy of this message
From: udo dot rader at bestsolution dot at Operating system: Ubuntu PHP version: 5.2.5 PHP Bug Type: Unknown/Other Function Bug description: utf8_decode Description: ------------ I have some JSON data genereated by GWT that is sent to the PHP server end. The JSON data recieved may contain special characters as well, that are regularly encoded as UTF8 (as required by the JSON specification). However, I find it impossible to access JSON data containing UTF8 encoded characters, because either utf8_decode or json_decode don't work as expected. Reproduce code: --------------- // this is how the JSON data is "normally" retrieved //$JSONInput = file_get_contents( "php://input" ); $JSONInput = '{"foo":"\xc3\xb6\xc3\xb6"}'; $decodedJSONData = utf8_decode( $sampleJSONData ); echo "decoded JSON data: ".$decodedJSONData."<br>"; if ( $sampleJSONData == $decodedJSONData ) { echo "decoded is equal<br>"; } if ( $sampleJSONData === $decodedJSONData ) { echo "decoded is binary equal<br>"; } Expected result: ---------------- I expect utf8_decode to really decode the given data. In the example from above, it should decode the "\xc3\xb6" part to ä (&auml; in HTML) Actual result: -------------- nothing is decoded at all. However decoding takes place, if one replaces the double quotes with single quotes and vice versa in the $JSONInput string. -- Edit bug report at http://bugs.php.net/?id=43375&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43375&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43375&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43375&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43375&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43375&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43375&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43375&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43375&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43375&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43375&r=support Expected behavior: http://bugs.php.net/fix.php?id=43375&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43375&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43375&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43375&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43375&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43375&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43375&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43375&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43375&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43375&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43375&r=mysqlcfg

« previous php.bugs (#119954) next »