Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the optimal multiplatform way of dealing with Unicode strings under C++?
    text
    copied!<p>I know that there are already several questions on StackOverflow about <code>std::string</code> versus <code>std::wstring</code> or similar but none of them proposed a full solution. </p> <p>In order to obtain a good answer I should define the requirements:</p> <ul> <li><strong>multiplatform</strong> usage, must work on Windows, OS X and Linux</li> <li>minimal effort for <strong>conversion to/from platform specific Unicode strings</strong> like <code>CFStringRef</code>, <code>wchar_t *</code>, <code>char*</code> as UTF-8 or other types as they are required by OS API. Remark: I don't need code-page convertion support because I expect to use only Unicode compatible functions on all operating systems supported.</li> <li>if requires an external library, this one should be <strong>open-source</strong> and under a very liberal license like BSD but not LGPL.</li> <li>be able to use a <strong>printf format</strong> syntax or similar.</li> <li>easy way of string allocation/deallocation </li> <li>performance is not very important because I assume that the Unicode strings are used only for application UI.</li> <li>some example could would be appreciated</li> </ul> <p>I would really appreciate only <strong>one proposed solution per answer</strong>, by doing this people may vote for their prefered alternative. If you have more than one alternative just add another answer.</p> <p>Please indicate something that <strong>did worked for you</strong>.</p> <p>Related questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/402283/stdwstring-vs-stdstring">stdwstring-vs-stdstring</a></li> <li><a href="https://stackoverflow.com/questions/621635/does-c0x-support-stdwstring-conversion-to-from-utf-8-byte-sequence">does-c0x-support-stdwstring-conversion-to-from-utf-8-byte-sequence</a></li> <li><a href="https://stackoverflow.com/questions/467139/portable-wchart-in-c">portable-wchart-in-c</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload