Jump to content
  • Advertisement
Sign in to follow this  
Decept

Unicode case conversion

This topic is 4357 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

Is there a function in C++ to change the case of a unicode string? The program I need this in is using MFC so if there are any such functions there it's also ok. I tried using the MakeUpper()/MakeLower() functions in the MFC CString class (the project is in Unicode). But they only change the case of the "standard" characters. For example, they just skip the "special" characters used in german. I'm using VC++ 2003

Share this post


Link to post
Share on other sites
Advertisement
have u tried _wcslwr and _wcsupr which are defined in <tchar.h>?

EDIT:
actually, nevermind... just checked MFC 8.0 (don't know about 7.0 which comes with VS 2003 though) source myself and saw MFC actually wraps the above functions. however, you might want to try messing with the locale versions of these functions, _wcslwr_l and _wcsupr_l. you can also try the Win32 API functions CharLower and CharUpper as well.

[Edited by - yadango on August 17, 2006 3:25:40 AM]

Share this post


Link to post
Share on other sites
The C++ functions for this are the toupper() member functions of the ctype locale facet. You'll need to create an appropriate locale for this though.

The standard C function for this is towupper(), but again the global locale needs to be set appropriately.

Share this post


Link to post
Share on other sites
If you're willing to Windows only and really care about getting things as right as you can the function to call is LCMapString. The problem with toupper and similiar functions is that they operate a character at a time and thus assume there's a one-to-one mapping between upper and lower case characters. In general this isn't true and it's possible for a string to end up being longer or shorter when you change it's case.

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!