? Success

User tests: Successful: Unsuccessful:

avatar elioair
elioair
26 May 2015

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.

avatar elioair elioair - open - 26 May 2015
avatar infograf768
infograf768 - comment - 27 May 2015

Please give test instructions.
How to reproduce the issue and check it is solved.

avatar Fedik
Fedik - comment - 27 May 2015

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

avatar zero-24 zero-24 - change - 27 May 2015
Labels Added: ? ?
avatar zero-24 zero-24 - change - 27 May 2015
Labels Added: ? ?
avatar elioair
elioair - comment - 27 May 2015

Thanks for your comments I have updated mine.

avatar zero-24 zero-24 - change - 27 May 2015
The description was changed
Labels Removed: ?
avatar infograf768
infograf768 - comment - 27 May 2015

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?

avatar elioair
elioair - comment - 27 May 2015

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.

avatar infograf768
infograf768 - comment - 27 May 2015

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);
    }
avatar zero-24 zero-24 - change - 27 May 2015
Category Libraries
avatar zero-24 zero-24 - change - 27 May 2015
Status New Pending
avatar elioair
elioair - comment - 27 May 2015

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 +

avatar infograf768
infograf768 - comment - 28 May 2015

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?

avatar elioair elioair - reference | 7bbf4d2 - 28 May 15
avatar elioair elioair - reference | 00c566d - 28 May 15
avatar elioair
elioair - comment - 28 May 2015

and add the desired code wherever needed?

Do you mean in other core files?

avatar infograf768
infograf768 - comment - 28 May 2015

Do you mean in other core files?

Yes.
@wilsonge @Bakual
What do you think?

avatar elioair
elioair - comment - 28 May 2015

OK, I'll be able to do so in a few days.

avatar brianteeman
brianteeman - comment - 11 Mar 2016

@elioair its been almost a year since your last comment


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7045.

avatar brianteeman brianteeman - change - 11 Mar 2016
Status Pending Information Required
avatar brianteeman
brianteeman - comment - 6 Apr 2016

Closed


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7045.

avatar brianteeman brianteeman - change - 6 Apr 2016
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2016-04-06 20:11:23
Closed_By brianteeman
avatar brianteeman brianteeman - close - 6 Apr 2016
avatar brianteeman brianteeman - close - 6 Apr 2016

Add a Comment

Login with GitHub to post a comment