title: c++ string to utf8 valid string using utf8proc
body: <p>I have a std::string output. Using utf8proc i would like to transform it into an valid utf8 string.
  <a href="http://www.public-software-group.org/utf8proc-documentation" rel="nofollow">http://www.public-software-group.org/utf8proc-documentation</a></p>
  
  <pre><code>typedef int int32_t;
  #define ssize_t int
  ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options)
  Reencodes the sequence of unicode characters given by the pointer buffer and length as UTF-8. The result is stored in the same memory area where the data is read. Following flags in the options field are regarded: (Documentation missing here) In case of success the length of the resulting UTF-8 string is returned, otherwise a negative error code is returned.
  WARNING: The amount of free space being pointed to by buffer, has to exceed the amount of the input data by one byte, and the entries of the array pointed to by str have to be in the range of 0x0000 to 0x10FFFF, otherwise the program might crash!
  </code></pre>
  
  <p>So first, how do I add an extra byte at the end? Then how do I convert from std::string to int32_t *buffer?</p>
  
  <p>This does not work:</p>
  
  <pre><code>std::string g = output();
  fprintf(stdout,"str: %s\n",g.c_str());
  g += " ";   //add an extra byte?? 
  g = utf8proc_reencode((int*)g.c_str(), g.size()-1, 0);
  fprintf(stdout,"strutf8: %s\n",g.c_str());  
  </code></pre>