#43375 [Opn->Bgs]: utf8_decode

From: Date: Mon, 08 Sep 2008 10:32:34 +0000
Subject: #43375 [Opn->Bgs]: utf8_decode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128768@lists.php.net to get a copy of this message
ID: 43375 Updated by: indeyets@php.net Reported By: udo dot rader at bestsolution dot at -Status: Open +Status: Bogus Bug Type: JSON related Operating System: Ubuntu PHP Version: 5.2.5 New Comment: Properly encoded "auml" character in json should be "\u00c4" not "\xc3\xb6" Previous Comments: ------------------------------------------------------------------------ [2007-11-22 13:02:31] udo dot rader at bestsolution dot at 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 this bug report at http://bugs.php.net/?id=43375&edit=1

« previous php.bugs (#128768) next »