ID:               50950
 Updated by:       johan...@php.net
 Reported By:      schlapn at mail dot 3dl dot am
-Status:           Open
+Status:           Bogus
 Bug Type:         JSON related
 Operating System: Windows
 PHP Version:      5.3.1
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

you have to use utf-8 encoded input. Make sure your file is saved as
utf-8orconvert the string.


Previous Comments:
------------------------------------------------------------------------

[2010-02-06 22:19:11] schlapn at mail dot 3dl dot am

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 this bug report at http://bugs.php.net/?id=50950&edit=1

Reply via email to