Force UTF-8 charset on JSON responses.

This commit is contained in:
Franz Liedke
2012-07-07 02:17:12 +03:00
parent 3ba5c00e5f
commit db9f220f57

View File

@@ -93,7 +93,7 @@ class Response {
*/ */
public static function json($data, $status = 200, $headers = array()) public static function json($data, $status = 200, $headers = array())
{ {
$headers['Content-Type'] = 'application/json'; $headers['Content-Type'] = 'application/json; charset=utf-8';
return new static(json_encode($data), $status, $headers); return new static(json_encode($data), $status, $headers);
} }
@@ -113,7 +113,7 @@ class Response {
*/ */
public static function eloquent($data, $status = 200, $headers = array()) public static function eloquent($data, $status = 200, $headers = array())
{ {
$headers['Content-Type'] = 'application/json'; $headers['Content-Type'] = 'application/json; charset=utf-8';
return new static(eloquent_to_json($data), $status, $headers); return new static(eloquent_to_json($data), $status, $headers);
} }