All responses from my Symfony 2 application have the following header line:
Content-Type: text/html
Therefore, my browser assumes the output encoding is ISO-8859-1. I would like the headline to say:
Content-Type: text/html; charset=utf8
instead of this. I know I can do it manually for every answer like this:
$response->setCharset('UTF-8');
But that would be incredibly redundant, since my application has many controls and will only output UTF-8. I searched in vain for setting up a symfony configuration that controls the default encoding. I found framework.charset , but it seems to be unrelated, and by default it is UTF-8.
How to get symfony to specify my encoding in all answers?
My thoughts
I know this is not a very big problem (most of the time), since I can explicitly specify the encoding in both HTML and XML. The problem is that I am serving plain text or JSON, or I am resetting variables with var_dump . In both cases, all non-ASCII characters are scrambled as my browser makes an erroneous guess.
My fallback is to subclass the response class and put $this->setCharset('UTF-8') in the constructor.
Hubro source share