php.net |  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
Votes:7
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: udo dot rader at bestsolution dot at
New email:
PHP Version: OS:

 

 [2007-11-22 13:02 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-08 10:32 UTC] indeyets@php.net
Properly encoded "auml" character in json should be "\u00c4" not "\xc3\xb6"
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Aug 12 06:01:25 2020 UTC