title: Special characters in object causes json_encode to throw error
body: <p>All hail the keepers of knowledge and may this stupid question reach you in good health,</p>
  
  <p>I've set forth to learn PHP, and as part of that glorious venture, I'm trying to create a RESTful API to a MySql DB. I'm using Slim on top of PHP 5.3. So far, so good. But I also live in Denmark, which is a problem (apparantly) because we like to use chars like 'æ', 'ø' and 'å'.</p>
  
  <p>So, when I ask my fantastic RESTful contraption for an object without strange chars, it politely replies:</p>
  
  <pre><code>{
  id: "3",
  name: "Wall - Plaster",
  price: "200",
  unit: "m2",
  tags: "1"
  }
  </code></pre>
  
  <p>But, alas. Things do not go so well when it is asked to return an object with an 'æ' or any other strange char:</p>
  
  <pre><code>FOOL! json_encode(): Invalid UTF-8 sequence in argument
  </code></pre>
  
  <p>utf8_encode() and Iconv.conv() works for strings and arrays. But what can I use for an object? Is there some way I could iterate my way through an object, like foreach? </p>
  
  <p>My DB and table are both in UTF8.</p>
  
  <p>My xenophobic function in question:</p>
  
  <pre><code>function getItem($id) {
          $sql = "SELECT * FROM items WHERE id=:id";
          try {
                  $db = getConnection();
                  $stmt = $db-&gt;prepare($sql);
                  $stmt-&gt;bindParam("id", $id);
                  $stmt-&gt;execute();
                  $item = $stmt-&gt;fetchObject();
                  $db = null;
                  echo json_encode($item);
                  //echo $item;
                  //print_r($item);
              } catch(PDOException $e) {
                  echo '{"error":{"text":'. $e-&gt;getMessage() .'}}';
              }
      }    
  </code></pre>
  
  <p>Thank you, and may virgins flock to you carrying gifts of fermented barley.</p>