How convert to utf8 string in c++
c++, string, utf-8
Solution
You should use the `icu::UnicodeString` methods `fromUTF8(const StringPiece &utf8)` or `toUTF8String(StringClass &result).`
Problem
I have a string output that ins not necessarily valid utf8. I have to pass it to a method only accepting valid utf8 strings. Therefore I need to convert output to the closest valid utf8 string removing invalid bytes or parts. How can I do that in c++? I would like not to use a 3rd party library.