Skip to content

Commit 4c1213a

Browse files
author
Chris Kacerguis
committed
1 parent 361092d commit 4c1213a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

application/libraries/Format.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,18 @@ public function to_json()
227227
$callback = isset($_GET['callback']) ? $_GET['callback'] : '';
228228
if ($callback === '')
229229
{
230-
return json_encode($this->_data);
230+
$str = $this->_data;
231+
array_walk_recursive($str, function(&$item, $key)
232+
{
233+
if(!mb_detect_encoding($item, 'utf-8', true))
234+
{
235+
$item = utf8_encode($item);
236+
}
237+
});
238+
239+
return json_encode($str);
231240
}
241+
232242
// we only honour jsonp callback which are valid javascript identifiers
233243
else if (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback))
234244
{

0 commit comments

Comments
 (0)