note 105789 added to function.json-encode

From: Date: Thu, 15 Sep 2011 07:39:46 +0000
Subject: note 105789 added to function.json-encode
Groups: php.notes 
Request: Send a blank email to php-notes+get-183183@lists.php.net to get a copy of this message
For PHP5.3 users who want to emulate JSON_UNESCAPED_UNICODE, there is simple way to do it: <?php function my_json_encode($arr) { //convmap since 0x80 char codes so it takes all multibyte codes (above ASCII 127). So such characters are being "hidden" from normal json_encoding array_walk_recursive($arr, function (&$item, $key) { if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); }); return mb_decode_numericentity(json_encode($arr), array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 83.17.133.60 ---- Manual Page -- http://www.php.net/manual/en/function.json-encode.php Edit -- https://master.php.net/note/edit/105789 Del: integrated -- https://master.php.net/note/delete/105789/integrated Del: useless -- https://master.php.net/note/delete/105789/useless Del: bad code -- https://master.php.net/note/delete/105789/bad+code Del: spam -- https://master.php.net/note/delete/105789/spam Del: non-english -- https://master.php.net/note/delete/105789/non-english Del: in docs -- https://master.php.net/note/delete/105789/in+docs Del: other reasons-- https://master.php.net/note/delete/105789 Reject -- https://master.php.net/note/reject/105789 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183183) next »