Solved

Trying to convert to upper case?

Posted on 2000-02-28
7
757 Views
Last Modified: 2008-02-26
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
0
Comment
Question by:eric07
7 Comments
 
LVL 2

Expert Comment

by:vbk_bgm
ID: 2567934
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
 

Author Comment

by:eric07
ID: 2567943
I'm not using MFC.  My project is an ATL not MFC based.  Is there an ANSII function to do this?

Thanks
0
 
LVL 5

Expert Comment

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

Regards,
Igor
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Accepted Solution

by:
hongjun earned 20 total points
ID: 2568083
#include <ctype.h>
#include <stdio.h>

void main()
{
....
  strDriveSelected = toupper(strDrive);
....
}
0
 
LVL 22

Expert Comment

by:nietod
ID: 2568340
>> 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
 
LVL 1

Expert Comment

by:JMu
ID: 2569348
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
 
LVL 22

Expert Comment

by:nietod
ID: 2569407
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ get user from AD  (VS6) 7 97
PDF library for Delphi 2 135
How to copy an image file into clipboard C/C++? 1 220
VS2015 Redefinition errors 4 91
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question