C++ & Boost: encode/decode UTF-8
Thanks everyone, but ultimately I resorted to http://utfcpp.sourceforge.net/ — it’s a header-only library that’s very lightweight and easy to use. I’m sharing a demo code here, should anyone find it useful: inline void decode_utf8(const std::string& bytes, std::wstring& wstr) { utf8::utf8to32(bytes.begin(), bytes.end(), std::back_inserter(wstr)); } inline void encode_utf8(const std::wstring& wstr, std::string& bytes) { utf8::utf32to8(wstr.begin(), wstr.end(), std::back_inserter(bytes)); } … Read more