Zend Framework

UTF8 character encoding for Zend_Json_Encoder

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.8.0
  • Component/s: Zend_Json
  • Labels:
    None

Description

Zend_Json_Encoder does not support encoding of UTF8 characters.

Zend_Json_Encoder::encode('Отладочный')

yields

"Отладочный"

instead of the following which is generated with json_encode() which does support UTF8 characters

"\u041e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439"

Issue Links

Activity

Hide
Christoph Dorn added a comment -

FYI: I am using this library for JSON encoding and it works great for UTF-8 characters.

http://pear.php.net/pepr/pepr-proposal-show.php?id=198

It is licensed under BSD.

Would it be possible to contact the authors to see if they can contribute the code to ZF or do you have other plans on how to incorporate UTF-8 encoding?

This is becoming an increasingly important issue for the FirePHP integration as well as international ZF userbase that uses AJAX.

Show
Christoph Dorn added a comment - FYI: I am using this library for JSON encoding and it works great for UTF-8 characters. http://pear.php.net/pepr/pepr-proposal-show.php?id=198 It is licensed under BSD. Would it be possible to contact the authors to see if they can contribute the code to ZF or do you have other plans on how to incorporate UTF-8 encoding? This is becoming an increasingly important issue for the FirePHP integration as well as international ZF userbase that uses AJAX.
Hide
Benjamin Eberlei added a comment -

The JSON Spec does not require unicode characters to be in ASCII Sequences

Show
Benjamin Eberlei added a comment - The JSON Spec does not require unicode characters to be in ASCII Sequences
Hide
Christoph Dorn added a comment -

The question then is; do we try and produce the same output as json_encode()?

Show
Christoph Dorn added a comment - The question then is; do we try and produce the same output as json_encode()?
Hide
Benjamin Eberlei added a comment -

i guess we should, and matthew had the same opinion on that.

I'll look into it.

Show
Benjamin Eberlei added a comment - i guess we should, and matthew had the same opinion on that. I'll look into it.
Hide
Benjamin Eberlei added a comment -

The incubator now holds a version of Zend_Json that has unicode transformation for both encoding and decoding making it consistant with json_encode()/json_decode()

Please test this with your use-cases (make sure to set the internal encoder decoder = true).

Show
Benjamin Eberlei added a comment - The incubator now holds a version of Zend_Json that has unicode transformation for both encoding and decoding making it consistant with json_encode()/json_decode() Please test this with your use-cases (make sure to set the internal encoder decoder = true).
Hide
Christoph Dorn added a comment -

Works like a charm. All my tests are still passing.

Show
Christoph Dorn added a comment - Works like a charm. All my tests are still passing.
Hide
clive darr added a comment -
Show
clive darr added a comment - quick fix $ svn co http://framework.zend.com/svn/framework/standard/incubator/library/Zend/Json/ worked for me
Hide
Benjamin Eberlei added a comment -

Moved from incubator to trunk in r14399, scheduled for 1.8 release

Show
Benjamin Eberlei added a comment - Moved from incubator to trunk in r14399, scheduled for 1.8 release

People

Vote (7)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: