public member function
result in ( stateT& state,
const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_limit, internT*& to_next ) const;
Translate in characters
Translates sequentially the characters in the range [from,from_end)
and places them in the range starting at to
. It does not attempt to store more characters once to_limit
When the function returns, from_next
point to one beyond the last element successfully converted.
The translation stops if a character cannot be translated, in which case it returns codecvt::error
If the destination range cannot absorb all the characters to be translated, or if the generation of a new translated character requires more characters beyond from_end
, it returns codecvt::partial
If both template parameters internT
are the same type, the function simply copies the contents and returns codecvt::noconv
On success, it returns codecvt::ok
During its operation, this function simply calls the virtual protected member codecvt::do_in
, which is the member function in charge of performing the actions described above.
- State object to keep track of the state of a multibyte character conversion. Typically, this is an object of type mbstate_t.
stateT is the state type (i.e., the third template parameter of codecvt).
- from, from_end
- Pointer to the initial and final characters of the source sequence. The range used is [from,from_end), which contains all the characters between from and from_end, including the character pointed by from but not the character pointed by from_end.
externT is the external character type (i.e., the second template parameter of codecvt).
- Pointer type able to point to an element in the above range. Once the function returns, this object points to the element in the source range beyond the last one successfully translated.
- to, to_limit
- Pointer to the initial and final characters of the destination sequence. The range used is [to,to_limit), which contains all the characters between to and to_limit, including the character pointed by to but not the character pointed by to_limit.
A translation does not necessarily need to fill up the range to its limit, and may also exhaust it (in which case it returns codecvt::partial).
internT is the internal character type (i.e., the first template parameter of codecvt).
- Pointer type able to point to an element in the above range. Once the function returns, this object points to the element in the destination range beyond the last one successfully translated.
An object of type codecvt::result
, with the following possible values:
|partial||Not all source characters converted|
|error||A character in the source could not be converted|
|noconv||Source and destination character types are the same. No conversion technique used.|
// codecvt::in example
using namespace std;
int main ()
const codecvt<wchar_t,char,mbstate_t>& myfacet =
char mystr = "Test string";
const size_t size = sizeof(mystr);
const char* pc;
// translate characters:
myresult = myfacet.in (mystate,
mystr, mystr+size, pc,
pwstr, pwstr+size, pwc);
if ( myresult == codecvt<wchar_t,char,mbstate_t>::ok )
cout << "Translation successful: ";
wcout << pwstr << endl;
Translation successful: Test string
- Translate out characters (public member function)
- Unshift translation state (public member function)
- Translate in characters [virtual] (protected virtual member function)