Laravel 5 charset not working correctly on the views. But it working well when I dump it from controller Laravel 5 charset not working correctly on the views. But it working well when I dump it from controller php php

Laravel 5 charset not working correctly on the views. But it working well when I dump it from controller


I solved this issue using this aswer. I've just went in my AppServiceProvider and put into boot method:

Blade::setEchoFormat('e(utf8_encode(%s))');

I don't know if this is the correct way to do it, but it works for me.


Generally sticking to UTF-8 keeps life simple.

Be super careful copying and pasting from anywhere else into your code - basically always go through Notepad++ and use its convert to UTF-8 (without BOM) before copying and pasting into your code.

First question - how is the data getting into your database?

Mega Top TipIf you're using a form, make sure you've set the accepted charset attribute on the form element:

<form accept-charset="UTF-8"

Then make sure all your views (including error pages), have

<meta charset="UTF-8">

Or the following if you're doing HTML4

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">


Since successful and error response do not behave consistently, the difference may be in the HTTP headers. If that's the case, what happens is that Sqlserver and your browser use the same encoding, likely some Windows default, like cp1252, while Laravel is configured to respond with a different charset than the one used in the database.

Check the HTTP header content-type both when you invoke the view and when you die() - if that is your issue configure Laravel to send some header that agrees with your templates and your database encoding (or of course! transcode explicitely when needed)