#include <iostream>
#include <vector>
#include <string>
#include <cwchar>
#include <clocale>
int main( )
{
std:: string s= "йаᠭ1" ;
std:: vector < std:: string > letters;
std:: setlocale ( LC_ALL, "" ) ; // or "en_US.utf8", or any other .utf8
std:: mbstate_t state = std:: mbstate_t ( ) ; // initial state
const char * ptr = s.c_str ( ) ;
const char * end = s.c_str ( ) + s.size ( ) ;
int len;
wchar_t wc;
while ( ( len = std:: mbrtowc ( & wc, ptr, end- ptr, & state) ) > 0 ) {
letters.push_back ( std:: string ( ptr, ptr+ len) ) ;
ptr + = len;
}
for ( size_t n = 0 ; n < letters.size ( ) ; ++ n)
std:: cout << "The size of the letter " << letters[ n] << " in UTF-8 is " << letters[ n] .size ( ) << '\n ' ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8Y3djaGFyPgojaW5jbHVkZSA8Y2xvY2FsZT4KaW50IG1haW4oKQp7CiAgICBzdGQ6OnN0cmluZyBzPSLQudCw4aCtMSI7CiAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gbGV0dGVyczsKCiAgICBzdGQ6OnNldGxvY2FsZShMQ19BTEwsICIiKTsgLy8gb3IgImVuX1VTLnV0ZjgiLCBvciBhbnkgb3RoZXIgLnV0ZjgKICAgIHN0ZDo6bWJzdGF0ZV90IHN0YXRlID0gc3RkOjptYnN0YXRlX3QoKTsgLy8gaW5pdGlhbCBzdGF0ZQogICAgY29uc3QgY2hhciogcHRyID0gcy5jX3N0cigpOwogICAgY29uc3QgY2hhciogZW5kID0gcy5jX3N0cigpICsgcy5zaXplKCk7CiAgICBpbnQgbGVuOwogICAgd2NoYXJfdCB3YzsKICAgIHdoaWxlKChsZW4gPSBzdGQ6Om1icnRvd2MoJndjLCBwdHIsIGVuZC1wdHIsICZzdGF0ZSkpID4gMCkgewogICAgICAgIGxldHRlcnMucHVzaF9iYWNrKHN0ZDo6c3RyaW5nKHB0ciwgcHRyK2xlbikpOwogICAgICAgIHB0ciArPSBsZW47CiAgICB9CgogICAgZm9yKHNpemVfdCBuID0gMDsgbiA8IGxldHRlcnMuc2l6ZSgpOyArK24pCiAgICAgICAgc3RkOjpjb3V0IDw8ICJUaGUgc2l6ZSBvZiB0aGUgbGV0dGVyICIgPDwgbGV0dGVyc1tuXSA8PCAiIGluIFVURi04IGlzICIgPDwgbGV0dGVyc1tuXS5zaXplKCkgPDwgJ1xuJzsKfQo=