Utf-8 encoding a std :: string?

I am using an api drawing that takes in const char * a string encoded by utf-8. Executing myStdString.cstr () does not work, api cannot draw a string.

eg:

sd::stringsomeText = "■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯▰▱";

will output ????????????????

So, how do I get std :: string to act correctly?

thank

+3
source share
2 answers

Try using std::codecvt_utf8to write a string to a string stream, and then pass the result ( stringstream::str) to the API.

+3
source

There are so many variables that are hard to figure out where to start.

, API UTF-8 O/S. , , Unicode.

. , UTF-8 , , , . std::wstring UTF-8. 128 , .

+3

Source: https://habr.com/ru/post/1772313/


All Articles