文字列をすべて大文字またはすべて小文字に変換せずに、C++ で大文字と小文字を区別しない文字列比較を行う最適な方法は何ですか?
メソッドが Unicode に対応しているかどうか、またどの程度移植性があるかを示してください。
ベストアンサー1
Boost には、このための便利なアルゴリズムが含まれています。
#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
}