|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-08 10:32 UTC] indeyets@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 22:00:01 2025 UTC |
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 ? (ä 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.