Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Using the Transform() Algorithm to Change a String's Case

The task of converting strings to uppercase is just like many other programming tasks: everyone needs it and everyone does it. The problem is with how they do it. Often it is done the hard wayreimplementing the wheel or introducing unnecessary performance penalties, maintenance problems, and other complexities. This month's solution demonstrates how the transform() algorithm is a faster, cleaner and more flexible method.


advertisement
ommand line interpreters, HTTP requests, and SMS messages are only a few of the applications in which different letter cases merely cause noise. To overcome this problem, such applications usually convert all strings to uppercase before any further processing.



Sadly, most of these apps use C-style strings and ad-hoc, in-house conversion routines that more often than not suffer from bugs, illegibility, and performance overhead. The std::string class provides more than a hundred member functions and overloaded operators. Yet, none of these functions transforms a string to uppercase or lowercase letters.



Use the STL transform() algorithm to change a string's case easily.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap