This repository was archived by the owner on Jan 30, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork28
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
utf8 encoded error #31
Open
Description
there is a problem when json_encode get an incorrect character but i have a solution:
in Json.php
private static function encodeViaPhpBuiltIn($valueToEncode, $prettyPrint = false){ if (! function_exists('json_encode') || static::$useBuiltinEncoderDecoder === true) { return false; } $encodeOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP; if ($prettyPrint) { $encodeOptions |= JSON_PRETTY_PRINT; } array_walk_recursive($valueToEncode, function(&$item, $key){ if(!mb_detect_encoding($item, 'utf-8', true)){ $item = utf8_encode($item); } }); $encoded = json_encode($valueToEncode, $encodeOptions | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); return $encoded ? $encoded : json_last_error_msg();}The new section is from array_walk_recursive().
Metadata
Metadata
Assignees
Labels
No labels