From eb8e3842fc77b2ae3f7491bef864f7c5de353869 Mon Sep 17 00:00:00 2001 From: Stefan Uhrig Date: Mon, 28 Mar 2005 17:15:54 +0000 Subject: [PATCH] Added toUpper() function --- src/utility/stringUtils.cpp | 12 ++++++++++++ vmime/utility/stringUtils.hpp | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/utility/stringUtils.cpp b/src/utility/stringUtils.cpp index 70d8aa8e..fd81297b 100644 --- a/src/utility/stringUtils.cpp +++ b/src/utility/stringUtils.cpp @@ -87,6 +87,18 @@ const string stringUtils::toLower(const string& str) } +const string stringUtils::toUpper(const string& str) +{ + string out(str); + const string::iterator end = out.end(); + + for (string::iterator i = out.begin() ; i != end ; ++i) + *i = std::toupper(*i, std::locale()); + + return (out); +} + + const string stringUtils::trim(const string& str) { string::const_iterator b = str.begin(); diff --git a/vmime/utility/stringUtils.hpp b/vmime/utility/stringUtils.hpp index 8dce55b2..8cfef69a 100644 --- a/vmime/utility/stringUtils.hpp +++ b/vmime/utility/stringUtils.hpp @@ -76,6 +76,14 @@ public: */ static const string toLower(const string& str); + /** Transform all the characters in a string to upper-case. + * \warning Use this with ASCII-only strings. + * + * @param str the string to transform + * @return a new string in upper-case + */ + static const string toUpper(const string& str); + /** Strip the space characters (SPC, TAB, CR, LF) at the beginning * and at the end of the specified string. *