title: Special characters stripped by mySQL/PHP JSON
body: <p>I have a simple PHP script to extract data from a mySQL database and encode it as JSON. The problem is that special characters (for example German ä or ß characters) are stripped from the JSON response. Everything after the first special character for any single field is just stripped.</p>
  
  <p>The fields are set to utf8_bin, and in phpMyAdmin the characters display correctly.</p>
  
  <p>The PHP script looks like this:</p>
  
  <pre><code>&lt;?php
  header("Content-type: application/json; charset=utf-8");
  
  $con = mysql_connect('database', 'username', 'password');
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("sql01_5789willgil", $con);
  
  $sql="SELECT * FROM weightevent";
  
  $result = mysql_query($sql);
  $row = mysql_fetch_array($result);
  
  $events = array();
  
  while($row = mysql_fetch_array($result))
  {
   $eventid = $row['eventid'];
   $userid = $row['userid'];
   $weight = $row['weight'];
   $sins = $row['sins'];
   $gooddeeds = $row['gooddeeds'];
   $date = $row['date'];
   $event = array("eventid"=&gt;$eventid, "userid"=&gt;$userid, "weight"=&gt;$weight, "sins"=&gt;$sins, 
   "gooddeeds"=&gt;$gooddeeds, "date"=&gt;$date);
   array_push($events, $event);
  }
  
  $myJSON = json_encode($events);
  
  echo $myJSON;
  
  mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p>Sample output:</p>
  
  <pre><code>[{"eventid":"2","userid":"1","weight":"70.1","sins":"Weihnachtspl","gooddeeds":"situps! lots and lots of situps!","date":"2011-01-02"},{"eventid":"3","userid":"2","weight":"69.9","sins":"A second helping of pasta...","gooddeeds":"I ate lots of salad","date":"2011-01-01"}]
  </code></pre>
  
  <p>--> in the first record the value for field 'sins' should be "Weihnachtsplätzchen".</p>
  
  <p>thanks very much!</p>