std::mbrtowc (3) - Linux Man Pages
Defined in header <cwchar>
std::size_t mbrtowc( wchar_t* pwc,
const char* s,
std::mbstate_t* ps );
Converts a narrow multibyte character to a wide character.
If s is not a null pointer, inspects at most n bytes of the multibyte character string, beginning with the byte pointed to by s to determine the number of bytes necessary to complete the next multibyte character (including any shift sequences). If the function determines that the next multibyte character in s is complete and valid, converts it to the corresponding wide character and stores it in *pwc (if pwc is not null).
If s is a null pointer, the values of n and pwc are ignored and call is equivalent to std::mbrtowc(NULL, "", 1, ps).
If the wide character produced is the null character, the conversion state stored in *ps is the initial shift state.
pwc - pointer to the location where the resulting wide character will be written
s - pointer to the multibyte character string used as input
n - limit on the number of bytes in s that can be examined
ps - pointer to the conversion state used when interpreting the multibyte string
The first of the following that applies:
* 0 if the character converted from s (and stored in pwc if non-null) was the null character
* the number of bytes [1...n] of the multibyte character successfully converted from s
* static_cast<std::size_t>(-2) if the next n bytes constitute an incomplete, but so far valid, multibyte character. Nothing is written to *pwc.
* static_cast<std::size_t>(-1) if encoding error occurs. Nothing is written to *pwc, the value EILSEQ is stored in errno and the value of *ps is left unspecified.
// Run this code
do_in converts a string from externT to internT, such as when reading from file