Created
June 6, 2019 08:39
-
-
Save Glamhoth/2d53a344bd49d82bd604af6fa9cf811d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <codecvt> | |
#include <iostream> | |
#include <locale> | |
#include <wchar.h> | |
int main() | |
{ | |
std::wstring test = L"łabądź"; | |
std::transform(test.begin(), test.end(), test.begin(), [&](wchar_t c) | |
{ | |
switch(c) | |
{ | |
case L'ł': | |
return L'l'; | |
break; | |
case L'ą': | |
return L'a'; | |
break; | |
case L'ź': | |
return L'z'; | |
break; | |
default: | |
return c; | |
break; | |
} | |
}); | |
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter; | |
std::string converted_test = converter.to_bytes(test); | |
std::cout << converted_test << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment