title: How to represent strings in a cross-platform (Windows, iOS, Android) C++ app?
body: <p>I am developing an application of which the core code base would be cross-platform for Windows, iOS and Android.</p>
  
  <p>My question is: how should I internally represent strings used by this app to be able to effectively use them on all three platforms?</p>
  
  <p>It is important to note, that I use DirectWrite heavily in Windows, of which the API functions usually expect wchar_t* to be passed (btw. the API documentation states that "A pointer to an array of Unicode characters.", I don't know whether this means that they are in UTF-16 encoding or not)</p>
  
  <p>I see three different approaches (however I find it quite difficult to grasp the details of handling Unicode strings with C++ in a cross-platform manner, so maybe I miss some important concept):</p>
  
  <ul>
  <li>use std::string internally everywhere (and store the strings in UTF-8 encoding?), and convert them to wchar_t* where it is needed for the DirectWrite API (I don't know what is needed by the text-processing APIs of Android and iOS yet).</li>
  <li>use std::wstring internally everywhere. If I understand things right, this wouldn't be effective from memory-usage perspective, because a wchar_t is 4 bytes on iOS and Android (and does it mean that i would have to store the string in UTF-16 on Windows, and in UTF-32 on Android/iOS?) </li>
  <li>create an abstraction for strings with an abstract base class, and implement internal storing specifically for the different platforms.</li>
  </ul>
  
  <p>What would be the best solution? And by the way, are there any existing cross-platform libraries that abstract string handling? (and also, reading and serializing of Unicode strings)</p>
  
  <p>(UPDATE: deleted the part with the question about the difference of char* and std::string.)</p>