Sign in to follow this  

A C++ UCS-2 string class?

This topic is 3310 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

This topic is 3310 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this