ifcplusplus
ifcplusplus copied to clipboard
wstring to string conversion
Hello,
I'm on Ubuntu 18.04 64 bit using gcc-8.
I need to convert std::wstring IfcObjectDefinition::m_Name->toString() to an actual UTF-8 std::string.
I've made sure my input file is encoded using UTF-8. And it reads fine in my terminal which is using the en_us.UTF-8 locale.
If I use std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(wstr) I get an std::range_error.
If I use boost::locale::conv::utf_to_utf<char, wchar_t>(str);, some characters are missing.
What is the expected way to convert the std::wstring to std::string?
Regards,
Hi, with Qt, there is a method QString::fromStdWString(...), so I used only that one so far. Other GUI libraries might have a similar function.
with Qt, there is a method QString::fromStdWString(...), so I used only that one so far.
In the Qt app I have bad results too: accentuated characters are corrupted. Which is the result I have too with boost::locale::conv::utf_to_utf<char, wchar_t>(str);.
solved meanwhile