#includeUnicodeString str1 = u"Hello World!"; UnicodeString str2 = u"Hello world!"; if (str1.compare(str2) == 0) { std::cout << "Strings are equal!\n"; } else { std::cout << "Strings are not equal!\n"; }
#includeIn this example, we compare two Unicode strings "Good morning!" and "Good afternoon!" using the compare function. As "morning" comes before "afternoon" in alphabetical order, the output will be "str1 comes before str2 in alphabetical order.". Package Library: ICU (International Components for Unicode) Library is likely to include the UnicodeString compare function in c++.UnicodeString str1 = u"Good morning!"; UnicodeString str2 = u"Good afternoon!"; if (str1.compare(str2) < 0) { std::cout << "str1 comes before str2 in alphabetical order.\n"; } else if (str1.compare(str2) > 0) { std::cout << "str1 comes after str2 in alphabetical order.\n"; } else { std::cout << "Both strings are equal!\n"; }