Код: Выделить всё
std::string str = "Hello! Привет!";
Код: Выделить всё
std::locale::global(std::locale("")); // Linux, UTF-8
std::string str = "Hello! Привет!";
std::string::size_type stringSize = str.size();
std::string::size_type nCharacters = 0;
std::string::size_type nextByte = 0;
std::string::size_type nBytesRead = 0;
std::mbtowc(nullptr, 0, 0); // What does it do, and why is it needed?
while (
(nBytesRead = std::mbtowc(nullptr, &str[nextByte], stringSize - nextByte))
!= 0)
{
++nCharacters;
nextByte += nBytesRead;
}
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/70432999/what-is-mbstate-t-and-why-to-reset-it[/url]
Мобильная версия