Asked  7 Months ago    Answers:  5   Viewed   32 times

How could one convert a string to upper case. The examples I have found from googling only have to deal with chars.

 Answers

56

Boost string algorithms:

#include <boost/algorithm/string.hpp>
#include <string>

std::string str = "Hello World";

boost::to_upper(str);

std::string newstr = boost::to_upper_copy<std::string>("Hello World");
Tuesday, June 1, 2021
 
fillobotto
answered 7 Months ago
56

http://en.wikipedia.org/wiki/Ascii#ASCII_control_code_chart

Binary   Oct  Dec    Hex    Abbr    Unicode  Control char  C Escape code   Name
0000000  000  0      00     NUL     ?       ^@                          Null character

There's no difference, but the more idiomatic one is ''.

Putting it down as char c = 0; could mean that you intend to use it as a number (e.g. a counter). '' is unambiguous.

Tuesday, June 22, 2021
 
samrap
answered 6 Months ago
70

Ruby has a few methods for changing the case of strings. To convert to lowercase, use downcase:

"hello James!".downcase    #=> "hello james!"

Similarly, upcase capitalizes every letter and capitalize capitalizes the first letter of the string but lowercases the rest:

"hello James!".upcase      #=> "HELLO JAMES!"
"hello James!".capitalize  #=> "Hello james!"
"hello James!".titleize    #=> "Hello James!"

If you want to modify a string in place, you can add an exclamation point to any of those methods:

string = "hello James!"
string.downcase!
string   #=> "hello james!"

Refer to the documentation for String for more information.

Tuesday, July 27, 2021
 
tadman
answered 5 Months ago
22

Apart from what you're doing is probably best done with XML APIs instead of strings or StringBuilder I doubt that the error you see is due to string concatenation. Maybe switching to StringBuilder just masked the error or went over it gracefully, but I doubt using strings really was the cause.

Friday, August 6, 2021
 
rlanvin
answered 4 Months ago
81

You're doing cout right? So obviously it gets displayed.

Maybe what you are trying to do is some code injection in a running process like this http://www.codeproject.com/KB/DLL/code_injection.aspx

Saturday, August 21, 2021
 
jlh
answered 4 Months ago
jlh
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share