Sign in to follow this  

Widechar string to tolower

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

Hi!
I've to convert a wide char string to tolower. This the code I used.


s32 id = profileList->getSelected();
stringw strtoDelete = profileList->getListItem(profileList->getSelected());
if(!strcmp(reinterpret_cast<const char*>(tolower(strtoDelete.c_str())),reinterpret_cast<const char*>("default")))
{
profileList->removeItem(id);
}




But I got the following errors:

Error 5 error C2143: syntax error : missing ')' before '{' d:\goldminer\source\game\gamemenuprofilestate.cpp 237
Error 4 error C2661: 'strcmp' : no overloaded function takes 1 arguments d:\goldminer\source\game\gamemenuprofilestate.cpp 236
Error 3 error C2664: 'tolower' : cannot convert parameter 1 from 'const wchar_t *' to 'int' d:\goldminer\source\game\gamemenuprofilestate.cpp 236
7 IntelliSense: argument of type "const wchar_t *" is incompatible with parameter of type "int" d:\goldminer\source\game\gamemenuprofilestate.cpp 236

How to convert a wide char string to tolower?

Share this post


Link to post
Share on other sites
tolower (I guess std::tolower) only works on single chars, try this instead:


static std::wstring ToLower( const std::wstring& String )
{
std::wstring Result( String );

for ( size_t i = 0; i < Result.length(); ++i )
{
Result[i] = std::tolower( Result[i], std::locale::classic() );
}
return Result;
}

Share this post


Link to post
Share on other sites

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