Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <string>
- #include <map>
- #include <sstream>
- std::wstring Compare(const std::wstring& first, const std::wstring second)
- {
- int result = CompareStringW(LOCALE_INVARIANT, NORM_IGNORENONSPACE, first.c_str(), -1, second.c_str(), -1);
- std::wostringstream os;
- std::map<int, std::wstring> resultmap;
- resultmap[CSTR_LESS_THAN] = L" < ";
- resultmap[CSTR_EQUAL] = L" == ";
- resultmap[CSTR_GREATER_THAN] = L" > ";
- if (result != 0)
- {
- os << first << resultmap[result] << second;
- }
- else
- {
- os << L"ERROR at CompareString, error code: 0x" << std::hex << GetLastError();
- }
- return os.str();
- }
- int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
- {
- std::wostringstream os;
- os << Compare(L"voila", L"voil\xE1") << std::endl;
- os << Compare(L"garcon", L"gar\xE7on") << std::endl;
- os << Compare(L"kase", L"k\xE4se") << std::endl;
- os << Compare(L"kase", L"kaese") << std::endl;
- os << Compare(L"arsita", L"ar\x15Fi\x163\x103") << std::endl;
- os << Compare(L"arsita", L"ar\x219i\x21B\x103") << std::endl;
- os << Compare(L"ar\x15Fi\x163\x103", L"ar\x219i\x21B\x103") << std::endl;
- MessageBoxW(0, os.str().c_str(), L"Comparison", 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement