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?
 
hongjunConnect With a Mentor Commented:
#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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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.