ID: 45594 Updated by: [EMAIL PROTECTED] Reported By: neonira at gmail dot com -Status: Open +Status: Bogus Bug Type: JSON related Operating System: windows XP PHP Version: 5.2.6 New Comment:
RTFM: "This function only works with UTF-8 encoded data." Previous Comments: ------------------------------------------------------------------------ [2008-07-22 15:32:45] neonira at gmail dot com Description: ------------ I checked that the file encoding character set for the php source file is UTF-8. So it means, I provide a real UTF-8 entry, and I don't need to use ut8_encode. It seems that accentuated caracters are truncated or not well managed while json-encoding a string. Reproduce code: --------------- <?php setlocale(LC_ALL, "fr"); class CT { var $link; var $str; var $arr; function document() { $this->link = "http://www.neonira.com"; $this->str = "chaîne avec caractères accentués ... "; $this->arr = array(1, 3, "lala", "123", array ( 'a', 'b', 'c'), 134); } } $c = new CT(); $c->document(); echo json_encode($c); ?> Expected result: ---------------- shell>php ../php/ct.php {"link":"http:\/\/www.neonira.com","str":"chaîne avec caractères accentués ... ","arr":[1,3,"lala","123",["a","b","c"],134]}shell> Actual result: -------------- shell>{107}php ../php/ct.php {"link":"http:\/\/www.neonira.com","str":"cha","arr":[1,3,"lala","123",["a","b","c"],134]}shell> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45594&edit=1