Skip to content

Commit cffc590

Browse files
j38600chriskacerguis
authored andcommitted
special chars encoding (chriskacerguis#858)
Special chars, such as "ç" and "ã", that are abundant in my language (portuguese) were being transformed into strange things. with this change, they're showing up just right...
1 parent 544f30b commit cffc590

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

application/libraries/Format.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,21 +406,21 @@ public function to_json($data = NULL)
406406

407407
if (empty($callback) === TRUE)
408408
{
409-
return json_encode($data);
409+
return json_encode($data, JSON_UNESCAPED_UNICODE);
410410
}
411411

412412
// We only honour a jsonp callback which are valid javascript identifiers
413413
elseif (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback))
414414
{
415415
// Return the data as encoded json with a callback
416-
return $callback.'('.json_encode($data).');';
416+
return $callback.'('.json_encode($data, JSON_UNESCAPED_UNICODE).');';
417417
}
418418

419419
// An invalid jsonp callback function provided.
420420
// Though I don't believe this should be hardcoded here
421421
$data['warning'] = 'INVALID JSONP CALLBACK: '.$callback;
422422

423-
return json_encode($data);
423+
return json_encode($data, JSON_UNESCAPED_UNICODE);
424424
}
425425

426426
/**

0 commit comments

Comments
 (0)