Convert to uppercase 
Author Message
 Convert to uppercase

Hi

How can I convert a string that contains special characters (for example ?,
?, ?, characters with accents) to uppercase.

/ Nisse



Wed, 22 Dec 2004 23:44:16 GMT  
 Convert to uppercase
Hi

Can toupper help?

e.g.,

std::string str;
str = ...
std::transform( str.begin(), std.end(), toupper );

Quote:

>Hi

>How can I convert a string that contains special characters (for example ?,
>?, ?, characters with accents) to uppercase.

>/ Nisse

--

Regards

Peter

As always the organisation disavows knowledge of this email



Thu, 23 Dec 2004 11:13:28 GMT  
 Convert to uppercase



Quote:
> Hi

> Can toupper help?

No, it cannot! Or, just maybe...

toupper is only required to work with the basic character set, while Nisse
is using extended characters. What happens when he calls toupper ranges from
works fine to crash and burn!

What happens to ?,?,? and accented characters depends on the current locale
(national conventions) *and* the current code page (where are the
characters). The C library toupper() has no konowledge whatsoever on this.

Sorry Nisse, you are at your own!

Bo Persson



Thu, 23 Dec 2004 16:19:26 GMT  
 Convert to uppercase
Maybe my answer won't be good, as it is platform dependant and non-STL, but
may help:
Use the Win32 API function "CharUpper" for a copied character sequence:
char* pChar = new char[str.length() + 1];
strcpy(pChar, str.c_str());
CharUpper(pChar);
str = pChar;
delete [] pChar;

Or if you using MSVC6, you can make an STL hack:
CharUpper(str.begin());
This technique doesn't work under MSVC7 and is not recommended at all, but
is much faster as the memory management under MSVC is very slow.

Regards,
Boris


Quote:
> Hi

> How can I convert a string that contains special characters (for example
?,
> ?, ?, characters with accents) to uppercase.

> / Nisse



Fri, 24 Dec 2004 16:30:58 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Converting string to uppercase.

2. Converting a string to uppercase.

3. How to convert uppercase/lowercase

4. How to convert an STL string to uppercase

5. Convert string to uppercase?

6. Converting lowercase string to uppercase easily?

7. Converting lowercase string to uppercase easily? - last word

8. Ree: Converting lowercase string to uppercase

9. Convert string to uppercase?

10. 3 ways to uppercase

11. uppercase to lowercase

12. how to uppercase a string

 

 
Powered by phpBB® Forum Software