Explicit function for obtaining 7-bit ascii, ryzom/ryzomcore#335

develop
kaetemi 4 years ago
parent 1ec9f16de4
commit 6ff5ddd790

@ -60,6 +60,7 @@ public:
u32string toUtf32() const; // Makes a copy
std::wstring toWide() const; // Platform dependent, UTF-16 or UTF-32. Makes a copy.
std::string toAscii() const; // Returns only values 0-127, 7-bit ASCII. Makes a copy.
inline bool isUtf8() const { return m_Iterator == utf8Iterator; }
inline bool isUtf16() const { return m_Iterator == utf16Iterator; }

@ -106,6 +106,21 @@ u32string CUtfStringView::toUtf32() const
return res;
}
std::string CUtfStringView::toAscii() const
{
std::string res;
res.reserve(m_Size);
for (iterator it(begin()), end(end()); it != end; ++it)
{
u32char c = *it;
if (c < 0x80)
res += c;
else
res += '_';
}
return res;
}
std::wstring CUtfStringView::toWide() const
{
#ifdef NL_OS_WINDOWS

Loading…
Cancel
Save