Jump to content
  • Advertisement
Sign in to follow this  
Guacamole

A C++ UCS-2 string class?

This topic is 3618 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
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.

Share this post


Link to post
Share on other sites
I need it to be portable, and IIRC the unicode standard advices againsusing wchar_t. I doubt basic_string<uint16> would do :D.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!