A C++ UCS-2 string class?

Started by
4 comments, last by Guacamole 15 years, 5 months ago
Does anyone know if there's a UCS-2 string class for C++ somewhere, under a commercially-viable license, that fits the concept of basic_string? I've been using ICU for a while, but now I need a basic_string compatible class, not the java-like UnicodeString. I don't need UTF-16, mere UCS-2 would be good. TIA
Advertisement
If you're using MSVC, wchar_t defaults to a 2-byte data type. So you can use std::wstring to suit your needs. Otherwise, you can provide your own template of basic_string with whatever sized datatype you want.
NextWar: The Quest for Earth available now for Windows Phone 7.
I need it to be portable, and IIRC the unicode standard advices againsusing wchar_t. I doubt basic_string<uint16> would do :D.
If you're using ICU, then std::basic_string<UChar> should work.
Depending on what exactly you mean by "UCS-2 string class", basic_string<uint16> may indeed work.

i.e., if all you need is a container for 16-bit codepoints with the standard string operators then it work fine.
-Mike
What about tiny caveats, like string comparisons? some scripts, like arabic, can be stored in "shaped" or "unshaped" variants, which *should* logically be equal. I assume basic_string<> won't do that for me by default, any workarounds?

This topic is closed to new replies.

Advertisement