Reputation: 31
That error occurs in my Laravel application in some Ajax requests, when the page is reloaded. Some requests fail and return the following response:
exception: "InvalidArgumentException"
file: "C:\wamp64\www\<my app directory>\vendor\laravel\framework\src\Illuminate\Http\JsonResponse.php"
line: 75
message: "Malformed UTF-8 characters, possibly incorrectly encoded"
What causes that error? How to fix it?
Upvotes: 3
Views: 16015
Reputation: 35337
This error is usually caused by the use of the standard string library instead of mbstring on utf8 characters.
Make sure you aren't using any str functions on any of the values prior to returning the JSON response. One time I hit this, I found a mutator in a model using substr instead of mb_substr.
Upvotes: 15