Boost includes a handy algorithm for this:

#include <boost/algorithm/string.hpp>
// Or, for fewer header dependencies:
//#include <boost/algorithm/string/predicate.hpp>

std::string str1 = "hello, world!";
std::string str2 = "HELLO, WORLD!";

if (boost::iequals(str1, str2))
{
    // Strings are identical
}
Answer from Rob on Stack Overflow
🌐
Boost
boost.org › doc › libs › 1_48_0 › boost › algorithm › string › compare.hpp
boost/algorithm/string/compare.hpp
This is a less restrictive version which wraps operator ==. */ struct is_equal { //! Function operator /*! Compare two operands for equality */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { return Arg1==Arg2; } }; //! case insensitive version of is_equal /*! Case insensitive comparison predicate.
🌐
Narkive
boost-users.boost.narkive.com › 2RCmYTwX › case-insensitive-less-than-string-comparison
case insensitive less_than string comparison
He's looking for something like is_iless, which I think would be a nice addition too string_algo. I see. Sorry about that. Somehow I have overlooked this obvious aspect. You are right, such a function can be usefull. I will add it (but it will have to wait after the release) Any thoughts on carrying this one step further. I've the case where I need not just case insensitivity, but more of an interleaved case sensitivity. For example using the following: int CompareInterleavedCaseChar( char a1, char a2 ) { if( std::toupper(a1) < std::toupper(a2) ) return -1; else if( std::toupper(a2) < std::toupper(a1) ) return 1; else if( a1 < a2 ) return -1; else if( a2 < a1 ) return 1; else return 0; } results in the following ordering: ABCdef ABcDef AbcDef Abcdef in other words A < a < B < b < C ...
🌐
Quora
quora.com › In-C-whats-the-best-way-to-do-case-insensitive-string-comparison
In C++ what's the best way to do case-insensitive string comparison? - Quora
Answer (1 of 20): First, you should read Jerry Coffin's answer to In C++ what's the best way to do case-insensitive string comparison?, which talks a little about why this problem is harder than it sounds. The easy answer, if you’re limiting yourself to the standard ASCII set, is that you conver...
🌐
Boost
boost.org › doc › libs › 1_45_0 › boost › algorithm › string › compare.hpp
boost/algorithm/string/compare.hpp - 1.45.0
This is a less restrictive version which wraps operator ==. */ struct is_equal { //! Function operator /*! Compare two operands for equality */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { return Arg1==Arg2; } }; //! case insensitive version of is_equal /*! Case insensitive comparison predicate.
🌐
O'Reilly
oreilly.com › library › view › c-cookbook › 0596007612 › ch04s14.html
4.13. Doing a Case-Insensitive String Comparison - C++ Cookbook [Book]
November 8, 2005 - 1 #include <string> 2 #include <iostream> 3 #include <algorithm> 4 #include <cctype> 5 #include <cwctype> 6 7 using namespace std; 8 9 inline bool caseInsCharCompareN(char a, char b) { 10 return(toupper(a) == toupper(b)); 11 } 12 13 inline bool caseInsCharCompareW(wchar_t a, wchar_t b) { 14 return(towupper(a) == towupper(b)); 15 } 16 17 bool caseInsCompare(const string& s1, const string& s2) { 18 return((s1.size() == s2.size()) && 19 equal(s1.begin(), s1.end(), s2.begin(), caseInsCharCompareN)); 20 } 21 22 bool caseInsCompare(const wstring& s1, const wstring& s2) { 23 return((s1.size() == s2.size()) && 24 equal(s1.begin(), s1.end(), s2.begin(), caseInsCharCompareW)); 25 } 26 27 int main() { 28 string s1 = "In the BEGINNING..."; 29 string s2 = "In the beginning..."; ...
Authors   D. Ryan StephensChristopher Diggins
Published   2005
Pages   594
🌐
Cplusplus
cplusplus.com › forum › beginner › 243351
Comparing strings regardless of case - C++ Forum
Sadly, there isn't really a built-in way to do case-insensitive string compare. At least not one that I know of. I suggest writing your own function, e.g. "iequals(a, b)" and convert each character to lower before comparing.
Find elsewhere
🌐
Boost
boost.org › doc › libs › 1_34_0 › boost › algorithm › string › predicate.hpp
boost/algorithm/string/predicate.hpp
Elements are compared case insensitively \param Arg1 First argument \param Arg2 Second argument \return The result of the test \note This function provides the strong exception-safety guarantee */ template · inline bool ilexicographical_compare( const Range1T& Arg1, const Range2T& Arg2) { return std::lexicographical_compare( begin(Arg1), end(Arg1), begin(Arg2), end(Arg2), is_iless()); } // all predicate -----------------------------------------------// //! 'All' predicate /*! This predicate holds it all its elements satisfy a given condition, represented by the predicate.
🌐
Broad-Hurst In Mart
martinbroadhurst.com › home › code › mastering case-insensitive string comparison in c++
C++ String Compare Ignore Case: The Ultimate Guider
October 31, 2023 - 1. Using Transform Method The std::transform function can convert both strings to lower (or upper) case and then compare them. 2. Leveraging Boost Library Ah, the wonders of Boost! The Boost library offers a iequals() function for case-insensitive ...
🌐
Cplusplus
cplusplus.com › forum › general › 86290
toupper compare array to string - C++ Forum
... There's also boost::algorithm::to_upper(input) demo: http://ideone.com/zkIE2x ref: http://www.boost.org/doc/libs/release/doc/html/boost/algorithm/to_upper.html As for case-insensitive comparison, there's boost::iequals(str1, str2)) demo (comparing array and string, as in OP): ...
🌐
Boost
boost.org › doc › libs › 1_41_0 › doc › html › boost › algorithm › istarts_with.html
Function template istarts_with - 1.41.0
boost::algorithm::istarts_with ... Range1T & Input, const Range2T & Test, const std::locale & Loc = std::locale()); This predicate holds when the test string is a prefix of the Input....
🌐
DEV Community
dev.to › marcobustillo › a-guide-to-case-insensitive-string-comparison-3339
A Guide to Case-Insensitive String Comparison - DEV Community
May 29, 2024 - There are times that we want to compare strings case-insensitive. We want to perform data validation,...
🌐
TutorialsPoint
tutorialspoint.com › case-insensitive-string-comparison-in-cplusplus
Case-insensitive string comparison in C++
This is a simple and straightforward approach for case-insensitive string comparison. Here the idea is to convert both the strings to lowercase or uppercase before comparing them.
🌐
Packtpub
subscription.packtpub.com › book › cloud-and-networking › 9781787282247 › 7 › 07lvl1sec74 › changing-cases-and-case-insensitive-comparison
Boost C++ Application Development Cookbook - Second ...
Access over 7,500 Programming & Development eBooks and videos to advance your IT skills. Enjoy unlimited access to over 100 new titles every month on the latest technologies and trends
🌐
Mitk
mitk.org › images › 3 › 3e › BugSquashingSeminars$13-11-06-bugsquashing-StringComparison.pdf pdf
11/14/13 (Case Insensitive) String Comparison in C++ Adrian Winterstein
std::string str2 = "Foo"; How to compare them case insensitive? The ==operator will not match. if ( boost::iequals(str1, str2) ) MITK_INFO << "Strings are equal."; Boost offers a solution: Page 5 · 11/14/13 | Adrian Winterstein · Departement MBI ·
🌐
Boost
boost.org › doc › libs › 1_85_0 › boost › algorithm › string › compare.hpp
boost/algorithm/string/compare.hpp - 1.85.0
This is a less restrictive version which wraps operator ==. */ struct is_equal { //! Function operator /*! Compare two operands for equality */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { return Arg1==Arg2; } }; //! case insensitive version of is_equal /*! Case insensitive comparison predicate.
🌐
Boost
boost.org › doc › libs › 1_33_1 › boost › algorithm › string › compare.hpp
boost/algorithm/string/compare.hpp - 1.33.1
This is a less restrictive version which wraps operator ==. */ struct is_equal { //! Function operator /*! Compare two operands for equality */ template< typename T1, typename T2 > bool operator ()( const T1& Arg1, const T2& Arg2 ) const { return Arg1==Arg2; } }; //! case insensitive version of is_equal /*! Case insensitive comparison predicate.