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);
Update
I discovered that if I die and dump the record on the web route it shows normal teste téste
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
Update 2
If I save my record like this PROMO - VIRICAPS (GUARANá + POLIVIT) 60 CáPS - CAIXA 18 UND
and dump($venda_item->produto->nomeproduto);
it returns me the right result with the accents.
All my database, including the column is set up to utf8mb4
and utf8mb4_unicode_ci
b'...'
are binary strings, introduced in 5.2 but deprecated by PHP 7. That they cause problems with JSON is known. There's no actual question in your post, that I can see. Can you clarify what you're wanting to know?utf8mb4
always and there won't be such problems.