Are you using a utf-8 column or a utf8mb4 column? That might your issue depending on your DB. It's a matter of whether it expects 3bytes or 4bytes per character.
Oct 13, 2017
4
Level 1
JSON: Malformed UTF-8 characters incorrectly encoded
Hello,
everytime i try to create a User with characters like "ä,ü,ö ... " i get this failure.
{
"message": "Error encoding model [App\\User] with ID [33] to JSON: Malformed UTF-8 characters, possibly incorrectly encoded",
"status_code": 500
}
This is my code:
public function register(Request $request)
{
$validator = $this->validateRequest($request);
if ($validator->fails()) {
return response()->json($validator->errors(), 404);
}
$user = $this->userRepository->insertUser($request);
$response = $this->response->item($user, new UserTransformer());
return response()->json([
'data' => [
'status' => 201,
'message' => 'User successfully created.',
'message_de' => 'Der Benutzer wurde erfolgreich erstellt.'
]
], 201);
}
The database is working fine.
Maybe someone of you can help my with this problem.
Thanks.
Level 1
@ejdelmonico thank you for your help. I found out that i had to use mb_strtolower() instead of strtolower() in my code. It's working now!
Please or to participate in this conversation.