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é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
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
If you already confirmed the encoding on your database. Have a look on config/database.php
, on charset and collation proprieties.
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci'
If the issue is on the "print" then you might use the utf8_encode
function.
{{utf8_encode($yourVar)}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With