Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with geting utf-8 characters #772

Closed
RazzaghShahidi opened this issue Mar 6, 2017 · 7 comments
Closed

issue with geting utf-8 characters #772

RazzaghShahidi opened this issue Mar 6, 2017 · 7 comments

Comments

@RazzaghShahidi
Copy link

RazzaghShahidi commented Mar 6, 2017

i got bad decoded json data.
my data are in persian and in my web are displayed well but in api getting bad characters.
for example:
i got in api :
{"manategh":[{"manategh_id":"51","manategh_name":"\u0634\u0644\u0645\u0686\u0647","manategh_picture":"24.jpg","manategh_description":"\u0645\u0648\u0642\u0639\u06cc\u062a \u062c\u063a\u0631\u0627\u0641\u06cc\u0627\u06cc\u06cc \u0634\u0644\u0645\u0686\u0647:\r\n\r\n\u0634\u0644\u0645\u0686\u0647 \u062f\u0631 \u06a9\u0634\u0648\u0631 \u0627\u06cc\u0631\u0627\u0646 \u060c \u0627\u0633\u062a\u0627\u0646 \u062e\u0648\u0632 }]}

@RazzaghShahidi
Copy link
Author

RazzaghShahidi commented Mar 6, 2017

i solved it by passing JSON_UNESCAPED_UNICODE to json_encode function.

file:
application\libraries\Format.php

in line 408:
return json_encode($data, JSON_UNESCAPED_UNICODE);
line 415:
return $callback.'('.json_encode($data, JSON_UNESCAPED_UNICODE).');';
line 422:
return json_encode($data, JSON_UNESCAPED_UNICODE);

and file:
application\libraries\REST_Controller.php
in line 1123:
... === TRUE ? json_encode($this->_args,JSON_UNESCAPED_UNICODE) : ...

@RazzaghShahidi
Copy link
Author

problem solved just for getting json.
in other formats the issue is remains.

@cshxxx
Copy link

cshxxx commented Mar 9, 2017

i have the same problem,ths.

@mohammed1955
Copy link

@RazzaghShahidi Work For Me ,So THANKS

@luckydonald
Copy link
Contributor

luckydonald commented Apr 27, 2018

@chriskacerguis I also hit this issue.
Searching from the issue tracker, there is need for it, but it was always just solved as work-around:
#675 #670 #622

Can we make that configurable,
so in future you won't need to change the libraries source code?

@luckydonald
Copy link
Contributor

luckydonald commented Apr 27, 2018

Like

if ($this->config->item('charset') == 'utf8') {
  return json_encode($data, JSON_UNESCAPED_UNICODE)
} else {
  return json_encode($data)
}

@qbingking
Copy link

i solved it by passing JSON_UNESCAPED_UNICODE to json_encode function.

file:
application\libraries\Format.php

in line 408:
return json_encode($data, JSON_UNESCAPED_UNICODE);
line 415:
return $callback.'('.json_encode($data, JSON_UNESCAPED_UNICODE).');';
line 422:
return json_encode($data, JSON_UNESCAPED_UNICODE);

and file:
application\libraries\REST_Controller.php
in line 1123:
... === TRUE ? json_encode($this->_args,JSON_UNESCAPED_UNICODE) : ...

yo man! it work fine, Vietnamese utf-8 wanna say thanks to you <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants