11 months ago

String with a "b" prefix on records with accent

Posted 11 months ago by spacedog4

When I dump the property of my model and it has an accent it returns with this "b" prefix

dump($venda_item->produto->nomeproduto); // b"teste téste"

My database is setted to utf8 and utf8_general_ci collation

This causes me the following error Malformed UTF-8 characters, possibly incorrectly encoded when I'm returning the response in json, at this line

$json_response = Response::json($response, $this->getStatusCode(), $headers);


I discovered that if I die and dump the record on the web route it shows normal teste tést

Route::get('/', function () {
    dd(App\Vendasitem::where('codigovi', 112685)->first()->produto->nomeproduto);

otherwise if I do the same in the controller or request and other files that I tryied it keeps returning me with the "b" prefix

Please sign in or create an account to participate in this conversation.