php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46325 Bug with json_encode and json_decode function
Submitted: 2008-10-17 08:38 UTC Modified: 2008-10-20 15:54 UTC
From: nihil dot kaos at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.2.6 OS: Win XP SP3
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:
MUST BE VALID
Solve the problem:
25 - 5 = ?
Subscribe to this entry?

 
 [2008-10-17 08:38 UTC] nihil dot kaos at gmail dot com
Description:
------------
The json_encode and the json_decode functions bug with the degree character ( '?' ). 

Reproduce code:
---------------
header("content-type: text");
$test = array();
$test['data'] = "test1?test2";
echo json_encode($test) . "\r\n";
print_r(json_decode('{"data":"test1?test2"}'));

Expected result:
----------------
{"data":"test1?test2"}
stdClass Object
(
    [data] => test1?test2
)


Actual result:
--------------
{"data":"test1"}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-20 15:54 UTC] lbarnaud@php.net
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

json functions accepts only valid UTF-8 characters. ASCII characters are UTF-8 compatible, but I guess '?' is not.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC