php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77274 json_encode white option JSON_UNESCAPED_UNICODE not work
Submitted: 2018-12-10 03:47 UTC Modified: 2018-12-10 11:37 UTC
From: mwd_3330410 at 163 dot com Assigned: cmb (profile)
Status: Not a bug Package: JSON related
PHP Version: 7.1.25 OS: All
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mwd_3330410 at 163 dot com
New email:
PHP Version: OS:

 

 [2018-12-10 03:47 UTC] mwd_3330410 at 163 dot com
Description:
------------
---
From manual page: https://php.net/function.json-encode
---
When the string contains special chars like ''(Hexadecimal character <0x14>),use the function json_encode($str, JSON_UNESCAPED_UNICODE) ,the result is \u0014 (PHP version 5.4 ~ 7.0).I don't know what the char is.Please check it and resove.

Test script:
---------------
echo json_encode('this is a test:my name is ABCÄÄÄÄ', JSON_UNESCAPED_UNICODE);

Expected result:
----------------
this is a test:my name is ABCÄÄÄÄ

Actual result:
--------------
this is a test:my name is ABCÄ\u0014Ä\u0014Ä\u0014Ä

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-10 11:37 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: *Unicode Issues +Package: JSON related -Assigned To: +Assigned To: cmb
 [2018-12-10 11:37 UTC] cmb@php.net
> this is a test:my name is ABCÄÄÄÄ

This would be invalid JSON, since according to RFC 7159[1]:

| All Unicode characters may be placed within the quotation marks,
| except for the characters that must be escaped: quotation mark,
| reverse solidus, and the control characters (U+0000 through
| U+001F).

[1] <https://tools.ietf.org/html/rfc7159#section-7>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 11 07:01:30 2024 UTC