php - Change charset in Laravel
730
Is there a way to change the default charset (UTF-8) to ISO-8859-1 in Laravel Framework?
I already tried:
Adding headers to routes;
$headers = array("Content-Type: text/html; charset=iso-8859-1");
Route::get('/notificacao/nova','[email protected]', $headers);
Answer
Solution:
I had your same problem and solved it adding a middleware which replaces UTF-8 with ISO-8859-1 in the Content-Type charset header.
I created a new middleware class, named
CharsetMiddleware
, with these contents:I put it in app/Http/Middleware/ folder, and then in app/Http/Kernel.php class added the class reference at the end of
$middleware
array property, like this: