User tests: Successful: Unsuccessful:
Added a check for the PHP (>= 5.4) version and JSON_UNESCAPED_UNICODE
to the return json_encode
statement of the__toString
method to display the unicode characters properly.
This addition is mostly suggested for the sake of convenience when the output is read by a human to check the json
formatting and see how the data is displayed.
It's not only about strings containing a few instances of unicode characters; the "real issue" occurs when the response contains mostly unicode characters like cyrillic or greek.
For example the following is a nightmare to be read by a human and check the data:
json_encode('йцукенгшщзхъ');
// "\u0439\u0446\u0443\u043a\u0435\u043d\u0433\u0448\u0449\u0437\u0445\u044a"
json_encode('ασδφγηξκλμνψω');
// "\u03b1\u03c3\u03b4\u03c6\u03b3\u03b7\u03be\u03ba\u03bb\u03bc\u03bd\u03c8\u03c9"
After the addition suggested the characters are displayed in a human friendly form and it is easier to read them.
also please add more explanation why do you want it
I do not see why this need,
if you see \u00e9
instead of é
it does not means that it is a problem for a program to read \u00e9
correct
Labels |
Added:
?
?
|
Labels |
Added:
?
?
|
Thanks for your comments I have updated mine.
Labels |
Removed:
?
|
After the addition suggested the characters are displayed in a human friendly form and it is easier to read them.
Where is it easier? In the database?
Where is it easier? In the database?
It is easier to read them when checking visually while developing if the data fetched is correct and to assess the overall json formatting. Also when it is in the form \uXXXX
, I've seen it causing some decoding issues when parsed from third party applications such as android apps.
OK. There are other files in core where we could do this I guess.
I tested OK in installer in
public function generateManifestCache()
{
return json_encode(self::parseXMLInstallFile($this->getPath('manifest')), JSON_UNESCAPED_UNICODE);
}
Category | ⇒ | Libraries |
Status | New | ⇒ | Pending |
Yes, apparently. You are right.
As a sidenote, the version check should be performed beforehand for the time being since JSON_UNESCAPED_UNICODE
was added on 5.4 and joomla's current minimum required version is 5.3.10 +
As a sidenote, the version check should be performed beforehand for the time being since JSON_UNESCAPED_UNICODE was added on 5.4 and joomla's current minimum required version is 5.3.10 +
sure, that was just a test I did using php 5.4.4
Can you correct this PR codestyle:
FILE: /home/travis/build/joomla/joomla-cms/libraries/cms/response/json.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
118 | ERROR | Expected "if (...)\n"; found "if (...) "
and add the desired code wherever needed?
and add the desired code wherever needed?
Do you mean in other core files?
OK, I'll be able to do so in a few days.
@elioair its been almost a year since your last comment
Status | Pending | ⇒ | Information Required |
Closed
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-06 20:11:23 |
Closed_By | ⇒ | brianteeman |
Please give test instructions.
How to reproduce the issue and check it is solved.