Skip to content

Instantly share code, notes, and snippets.

@Glamhoth
Created June 6, 2019 08:39
Show Gist options
  • Save Glamhoth/2d53a344bd49d82bd604af6fa9cf811d to your computer and use it in GitHub Desktop.
Save Glamhoth/2d53a344bd49d82bd604af6fa9cf811d to your computer and use it in GitHub Desktop.
#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