From: schlapn at mail dot 3dl dot am
Operating system: Windows
PHP version: 5.3.1
PHP Bug Type: JSON related
Bug description: json_encode null some special chars
Description:
------------
Hi,
I got the following array and want to enode it to json format:
print_r($hier);
------
["ID"]=> int(254) ["XYID"]=> int(4) ["Inhalt"]=> string(127)
"@hallowas geht " ["Name"]=> string(4) "falti" ["Datum"]=> string(19)
"2010-02-06 17:57:54" ["Gruß"]=> string(14) "TOOTO|§§|MOOTO" ["Affe"] =>
string (4) "Pans"
------
but the result was
print_r(json_encode($hier));
----
{"ID":254,"XYID":4,"Inhalt":"@hallowas geht
","Name":"falti","Datum":"2010-02-06 17:57:54","Gruß":null,"Affe":"Pans"}
---
As you can see the string with the '§' char results a null in the encoded
JSON. I uses the option Paramters
(JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP) but nothing solved
the problem, when I used other chars instead it worked properly.
I saw someone having this Problem on a Linux and MacOs Machine with PHP
5.3 but the bug is still there on Windows machines with PHP 5.3.1
Reproduce code:
---------------
print_r($hier);
------
["ID"]=> int(254) ["XYID"]=> int(4) ["Inhalt"]=> string(127)
"@hallowas geht " ["Name"]=> string(4) "falti" ["Datum"]=> string(19)
"2010-02-06 17:57:54" ["Gruß"]=> string(14) "TOOTO|§§|MOOTO" ["Affe"] =>
string (4) "Pans"
------
results:
print_r(json_encode($hier));
----
{"ID":254,"XYID":4,"Inhalt":"@hallowas geht
","Name":"falti","Datum":"2010-02-06 17:57:54","Gruß":null,"Affe":"Pans"}
---
Expected result:
----------------
print_r($hier);
------
["ID"]=> int(254) ["XYID"]=> int(4) ["Inhalt"]=> string(127)
"@hallowas geht " ["Name"]=> string(4) "falti" ["Datum"]=> string(19)
"2010-02-06 17:57:54" ["Gruß"]=> string(14) "TOOTO|§§|MOOTO" ["Affe"] =>
string (4) "Pans"
------
but the result was
print_r(json_encode($hier));
----
{"ID":254,"XYID":4,"Inhalt":"@hallowas geht
","Name":"falti","Datum":"2010-02-06
17:57:54","Gruß":"TOOTO|§§|MOOTO","Affe":"Pans"}
---
Actual result:
--------------
print_r(json_encode($hier));
----
{"ID":254,"XYID":4,"Inhalt":"@hallowas geht
","Name":"falti","Datum":"2010-02-06 17:57:54","Gruß":null,"Affe":"Pans"}
---
--
Edit bug report at http://bugs.php.net/?id=50950&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50950&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50950&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50950&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50950&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50950&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50950&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50950&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50950&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50950&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50950&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50950&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50950&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50950&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50950&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50950&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50950&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50950&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50950&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50950&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50950&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50950&r=mysqlcfg