title: PHP UTF8 encoding issue with Special characters
body: <p>I am using PHP to connect to a database and retrieve mostly strings. These strings are sentences written in Portuguese, therefore they have plenty of "é", "ç", "ú", etc...</p>
  
  <p>When retrieving I'm doing this:</p>
  
  <pre><code>$res = sqlsrv_query($conn,$query);
  $array_req = array();
  
  while($rs = sqlsrv_fetch_object($res)){
      // Get info request
      $temp_req = array();
      $temp_req['id'] = $rs-&gt;id;
      $temp_req['title'] = utf8_decode($rs-&gt;title);
      ...
  }
  echo json_encode(array('result'=&gt;$array_req));
  </code></pre>
  
  <p>And by doing that <em>utf8_decode</em> characters like "ç" get replaced by "?" for example. If I don't do the decoding then the text is all well since it is correctly stored on the database. However, if I don't do the decoding, the <em>json_encode</em> will retrieve the strings as <em>null</em>.</p>
  
  <p>How do I keep the characters? I already tried <em>mb_convert_encoding</em>, <em>htmlspecialchars</em>, nothing seems to work.</p>
  
  <p>EDIT: This script was being requested by an Android app. However I was testing on the browser and it seems if I actually encode the strings in UTF8 and send the json with the flag <em>JSON_UNESCAPED_UNICODE</em> sugested below, the browser still returns bad characters but the android app reads them ok. Go figure...
  This is the working code:</p>
  
  <pre><code>$res = sqlsrv_query($conn,$query);
  $array_req = array();
  
  while($rs = sqlsrv_fetch_object($res)){
      // Get info request
      $temp_req = array();
      $temp_req['id'] = $rs-&gt;id;
      $temp_req['title'] = utf8_encode($rs-&gt;title);
      ...
  }
  echo json_encode(array('result'=&gt;$array_req), JSON_UNESCAPED_UNICODE);
  </code></pre>