title: How to handle unicode values in JSON strings?
body: <p>I'm writing a JSON parser in C++ and am facing a problem when parsing JSON strings:</p>
  
  <p>The JSON specification states that JSON strings can contain unicode characters in the form of:</p>
  
  <pre><code>"here comes a unicode character: \u05d9 !"
  </code></pre>
  
  <p>My JSON parser tries to map JSON strings to <code>std::string</code> so usually, one character of the JSON strings becomes one character of the <code>std::string</code>. However for those unicode characters, I really don't know what to do:</p>
  
  <p>Should I just put the raw bytes values in my <code>std::string</code> like so:</p>
  
  <pre><code>std::string mystr;
  mystr.push_back('\0x05');
  mystr.push_back('\0xd9');
  </code></pre>
  
  <p>Or should I interpret the two characters with a library like <code>iconv</code> and store the UTF-8 encoded result in my string instead ?</p>
  
  <p>Should I use a <code>std::wstring</code> to store all the characters ? What then on *NIX OSes where <code>wchar_t</code> are 4-bytes long ?</p>
  
  <p>I sense something is wrong in my solutions but I fail to understand what. What should I do in that situation ?</p>