Trying to convert to upper case?

I have the following code.  I need to make sure that is in upper case.  How do you do this with basic_string:

typedef basic_string<TCHAR> CStr;

Then somewhere in my function I do the
following:

CStr strDriveSelected;

strDriveSelected = OLE2T( strDrive );

What is the best way to conver it to
an upper case.  So if strDrive is "a"
strDriveSelected becomes "A"

THanks
eric07Asked:
Who is Participating?
 
hongjunCommented:
#include <ctype.h>
#include <stdio.h>

void main()
{
....
  strDriveSelected = toupper(strDrive);
....
}
0
 
vbk_bgmCommented:
Method 1
You can use CharUpperBuff(LPTSTR lpsz,
DWORD length) to convert the string into uppercase
Method 2
Use CString::MakeUpper to convert the string into uppercase after assigning it to a CString variable.
0
 
eric07Author Commented:
I'm not using MFC.  My project is an ATL not MFC based.  Is there an ANSII function to do this?

Thanks
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
proskigCommented:
Hi,
This code should help you:
_tcsupr(const_cast<TCHAR*>(strDriveSelected.data()));

Regards,
Igor
0
 
nietodCommented:
>> This code should help you:
>> _tcsupr(const_cast<TCHAR*>(strDriveSelected.data()));
Not really!  Don't ever do that.  That can mess up other strings.
0
 
JMuCommented:
Please, don't use toupper. It doesn't work in Finland for example. We have letters like åäö and their uppercase equivalents ÅÄÖ.

toupper works only for a to z.

JMu
0
 
nietodCommented:
The STL toupper() template function allows you to specify a locale so that this can be made to work in any language (and with any character representation.)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.