|  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
 [2018-12-10 03:47 UTC] mwd_3330410 at 163 dot com
From manual page:
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Ä


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-10 11:37 UTC]
-Status: Open +Status: Not a bug -Package: *Unicode Issues +Package: JSON related -Assigned To: +Assigned To: cmb
 [2018-12-10 11:37 UTC]
> 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] <>
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Dec 07 18:01:29 2023 UTC