Added toAscii overload

This commit is contained in:
Daniel Wolf 2016-12-20 20:04:43 +01:00
parent 2cce8eebd9
commit e415d59c16
2 changed files with 11 additions and 0 deletions

View File

@ -108,6 +108,15 @@ string toAscii(const u32string& s) {
return result;
}
string toAscii(const wstring& s) {
string result;
for (wchar_t ch : s) {
optional<char> ascii = toAscii(ch);
if (ascii) result.append(1, *ascii);
}
return result;
}
u32string utf8ToUtf32(const string& s) {
#if defined(_MSC_VER) && _MSC_VER <= 1900
// Workaround for Visual Studio 2015

View File

@ -16,6 +16,8 @@ boost::optional<char> toAscii(char32_t ch);
std::string toAscii(const std::u32string& s);
std::string toAscii(const std::wstring& s);
std::u32string utf8ToUtf32(const std::string& s);
template<typename T>