Answer the question
In order to leave comments, you need to log in
How to get rid of Malformed UTF-8 characters, possibly incorrectly encoded error?
I tried to change the output of the exception in the Handler, then I get the response Malformed UTF-8 characters, possibly incorrectly encoded.
public function render($request, Exception $exception)
{
if ($exception instanceof ValidationException){
$message = '';
foreach ($exception->errors() as $error){
foreach ($error as $rule){
$message .= '.'.$rule;
}
}
$response['message'] = substr($message, 2);
return $this->apiResponse($response);
}
return parent::render($request, $exception);
}
function apiResponse($response = [], $success = true, $status = 400, $message = '')
{
$headers = ['Content-type' => 'application/json; charset=utf-8'];
$response = [
'error' => $status,
'success' => $success,
'message' => $message,
'response' => $response ? $response : new \stdClass(),
];
return response()->json($response, $status, $headers, JSON_UNESCAPED_UNICODE);
}
Answer the question
In order to leave comments, you need to log in
I think this might help:
https://stackoverflow.com/questions/46305169/php-j...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question