public member function
result out ( stateT& state,
const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_limit, externT*& to_next ) const;
Translate out 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_out
, 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.
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 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).
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 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::out example
using namespace std;
int main ()
mbstate_t mystate = mbstate_t();
const codecvt<wchar_t,char,mbstate_t>& myfacet =
cout << "Enter sentence: ";
size_t length = mywstring.length();
char* pstr= new char [length+1];
const wchar_t* pwc;
// translate characters:
myresult = myfacet.out (mystate,
mywstring.c_str(), mywstring.c_str()+length+1, pwc,
pstr, pstr+length+1, pc);
if ( myresult == codecvt<wchar_t,char,mbstate_t>::ok )
cout << "Translation successful: " << pstr << endl;
Enter sentence: Test sentence
Translation successful: Test sentence
- Translate in characters (public member function)
- Translate out characters [virtual] (protected virtual member function)