php - How do I get Symfony to specify my charset in all responses? -


all responses symfony 2 application have header line:

content-type: text/html 

so browser assumes output charset iso-8859-1. header say:

content-type: text/html; charset=utf8 

instead. know can manually every response this:

$response->setcharset('utf-8'); 

but incredibly redundant since application has lots of controls , ever output utf-8. have searched in vain symfony configuration setting controls default charset. found framework.charset seems unrelated, , utf-8 default anyway.

how symfony specify charset in responses?


my thoughts

i know isn't of problem (most of time) since can specify charset explicitly in both html , xml. issue when i'm service plain text or json, or if i'm dumping variables using var_dump. in both cases, non-ascii symbols scrambled browser ventures erroneous guess.

my backup solution subclass response class , put $this->setcharset('utf-8') in constructor.

i think can tell framework charset use in config.yml:

framework:   charset:         utf-8 

see: http://symfony.com/doc/current/reference/configuration/framework.html


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -