Note that there are some explanatory texts on larger screens.

plurals
  1. PONew unicode characters in C++0x
    primarykey
    data
    text
    <p>I'm buiding an API that allows me to fetch strings in various encodings, including utf8, utf16, utf32 and wchar_t (that may be utf32 or utf16 according to OS).</p> <ol> <li><p>New C++ standard had introduced new types <code>char16_t</code> and <code>char32_t</code> that do not have this sizeof ambiguity and should be used in future, so I would like to support them as well, but the question is, <strong>would they interfere</strong> with normal <code>uint16_t</code>, <code>uint32_t</code>, <code>wchar_t</code> types not allowing overload because they may refer to same type?</p> <pre><code>class some_class { public: void set(std::string); // utf8 string void set(std::wstring); // wchar string utf16 or utf32 according // to sizeof(wchar_t) void set(std::basic_string&lt;uint16_t&gt;) // wchar independent utf16 string void set(std::basic_string&lt;uint32_t&gt;); // wchar independent utf32 string #ifdef HAVE_NEW_UNICODE_CHARRECTERS void set(std::basic_string&lt;char16_t&gt;) // new standard utf16 string void set(std::basic_string&lt;char32_t&gt;); // new standard utf32 string #endif }; </code></pre> <p>So I can just write:</p> <pre><code>foo.set(U"Some utf32 String"); foo.set(u"Some utf16 string"); </code></pre></li> <li><p>What are the typedef of <code>std::basic_string&lt;char16_t&gt;</code> and <code>std::basic_string&lt;char32_t&gt;</code> as there is today:</p> <pre><code>typedef basic_string&lt;wchar_t&gt; wstring. </code></pre> <p>I can't find any reference.</p> <p>Edit: according to headers of gcc-4.4, that introduced these new types:</p> <pre><code>typedef basic_string&lt;char16_t&gt; u16string; typedef basic_string&lt;char32_t&gt; u32string; </code></pre> <p>I just want to make sure that this is actual standard requirement and not gcc-ism.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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