title: Symfony2 JsonResponse utf8 encoding issues on Debian Stable php-5.4
body: <p>I'm having issues with JsonResponse on Debian Stable php5 (5.4.39-0+deb7u1) when returning UTF8 chars.</p>
  
  <p>I developed an app on Debian Testing php5 (5.6.6+dfsg-2) and the following code worked like a charm:</p>
  
  <pre><code>$response = new JsonResponse();
  $response-&gt;headers-&gt;set('Content-Type', 'application/json');
  $response-&gt;setData($data);
  return $response;
  </code></pre>
  
  <p>but after deploying to the stable prod server I started getting the following exception for the exact same DB/Data charsets etc:</p>
  
  <pre><code>request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "Malformed UTF-8 characters, 
  possibly incorrectly encoded." at /site/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/JsonResponse.php
   line 123 {"exception":"[object] (InvalidArgumentException(code: 0): 
  Malformed UTF-8 characters, possibly incorrectly encoded. at 
  /site/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/JsonResponse.php:123)"} []
  </code></pre>
  
  <p>The response from DB that is passed as $data DO contains UTF8 chars that I can't control. I just have to display them.</p>
  
  <p>I suppose I hit a bug of 5.4, but how can I easily walk around it?
  I did tried:</p>
  
  <pre><code>    $response = new JsonResponse();
      $response-&gt;headers-&gt;set('Content-Type', 'application/json');
      $response-&gt;setEncodingOptions(JSON_UNESCAPED_UNICODE);
      $response-&gt;setData($data);
      return $response;
  </code></pre>
  
  <p>but I get the same error.</p>
  
  <p>Ideas?</p>