title: How to send special characters to php server
body: <p>I am traying to send special characters to a php server. I tried with angular and with jquery getting the same result:</p>
  
  <p>myClient.js with JQuery:</p>
  
  <pre><code>data = "Ñoñón";
  dataToSend={special_word: data};
  $.ajax({    
    type : 'POST',
    url  : 'myServer.php',
    data : dataToSend,
    success :  function(response){
      console.log(response);
   }
  });
  </code></pre>
  
  <p>myServer.php for JQuery client:</p>
  
  <pre><code>$special_word =mysqli_real_escape_string($mysqli, $_POST["special_word"]));
  saveWordInDB($special_word);
  echo $special_word;
  </code></pre>
  
  <p>myClient.js with angular:</p>
  
  <pre><code>data = "Ñoñón";
  dataToSend={special_word: data};
  $http.post('myServer.php', dataToSend)
  .then(
     function(response){
       // success callback
       console.log(response.data);
     }, 
     function(response){
       // failure callback
       console.log(response);
     }
  );
  </code></pre>
  
  <p>myServer.php for angular client</p>
  
  <pre><code>$postdata = file_get_contents("php://input");
  $request = json_decode($postdata);
  $special_word = $request-&gt;special_word;
  saveWordInDB($special_word);
  echo $special_word;
  </code></pre>
  
  <p>In both cases, the word "Ñoñón" is not stored in the DB, but the word "Ã±oÃ±Ã³n" its stored instead. The same occurs with the word showed in the console. How can this be fixed?</p>
  
  <p>Thanks in advance!</p>