title: symfony2 utf8 issue with translation in the controller
body: <p>In my symfony 2 application, I am translating a string in a controller, from a yaml file, and sending it via ajax.</p>
  
  <p>Then in my ajax function, I am parsing the response with JSON</p>
  
  <p>The issue I have is the string that is being output by the translator is not in UTF8. Why? It is in the right format when I call the filter | trans in my templates.</p>
  
  <p>Also, accentuated letters written in my controller are correctly sent in UTF8, it really seems to come from the translating component. </p>
  
  <p>The workaround I found is to encode in UTF8 after it is translated in my controller, send it via ajax, then decode UTF8 in javascript. But it's not super clean plus I can get "this is not a URI" errors.</p>
  
  <p><strong>How can I have the translator output a UTF8 string in my controller ?</strong></p>
  
  <p>My yaml:</p>
  
  <pre><code>rights:
      is_boss: Tout éditer, voir, supprimer
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>    $message= strtolower($translator-&gt;trans('rights.is_boss', array(), 'backend_pages'));
  
      $response = array(
          'message' =&gt; utf8_encode($message)
      );
  
      return new JsonResponse($this-&gt;get('serializer')-&gt;serialize($response, 'json'));
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>        $.ajax({
              type        : 'POST',
              url         : '{{ path('manage_rights', {'associate' : associate.id }) }}',
              data: {right: right, parameter: parameter, value: value},
              dataType: 'json'
          }).done(function(response){
              response = JSON.parse(response);
              var message = decodeURIComponent(escape(response.message));
              //do stuff
          })
  </code></pre>
  
  <p>The error I get if I don't encode in UTF 8 is the following:</p>
  
  <blockquote>
    <p>Your data could not be encoded because it contains invalid UTF8
    characters. 500 Internal Server Error - RuntimeException
    in
    vendor\jms\serializer\src\JMS\Serializer\JsonSerializationVisitor.php
    at line 36   -</p>
  </blockquote>
  
  <p>Precision:</p>
  
  <pre><code>//This does not output a proper UTF8 string. I get an error if I try to serialize it in JSON
  $message= strtolower($translator-&gt;trans('rights.is_boss', array(), 'backend_pages'));
  
  //In my twig, this does output a correct string with accentuated chars without weird symbols
  &lt;label&gt;{{ ('rights.is_boss') | trans }}&lt;/label&gt;
  </code></pre>