|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43375 utf8_decode
Submitted: 2007-11-22 13:02 UTC Modified: 2008-09-08 10:32 UTC
Avg. Score:4.6 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:2 (33.3%)
From: udo dot rader at bestsolution dot at Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.2.5 OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
45 + 23 = ?
Subscribe to this entry?

 [2007-11-22 13:02 UTC] udo dot rader at bestsolution dot at
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-08 10:32 UTC]
Properly encoded "auml" character in json should be "\u00c4" not "\xc3\xb6"
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jun 06 17:03:39 2023 UTC