title: How do I get Symfony to specify my charset in all responses?
body: <p>All responses from my Symfony 2 application all have this header line:</p>
  
  <pre><code>Content-Type: text/html
  </code></pre>
  
  <p>So my browser assumes the output charset is ISO-8859-1. I would like the header to say:</p>
  
  <pre><code>Content-Type: text/html; charset=utf8
  </code></pre>
  
  <p>instead. I know I can do this manually for every response like this:</p>
  
  <pre><code>$response-&gt;setCharset('UTF-8');
  </code></pre>
  
  <p>But that would be incredibly redundant since my application has lots of controls and will only ever output UTF-8. I have searched in vain for a Symfony configuration setting that controls the default charset. I found <code>framework.charset</code> but that seems to be unrelated, and is UTF-8 by default anyway.</p>
  
  <p>How do I get Symfony to specify my charset in all responses?</p>
  
  <hr>
  
  <h2>My thoughts</h2>
  
  <p>I know this isn't too much of a problem (most of the time) since I can specify the charset explicitly in both HTML and XML. The issue is when I'm service plain text or JSON, or if I'm dumping variables using <code>var_dump</code>. In both cases, all non-ASCII symbols are scrambled as my browser ventures an erroneous guess.</p>
  
  <p>My backup solution is to subclass the response class and put <code>$this-&gt;setCharset('UTF-8')</code> in the constructor.</p>