std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::to_bytes (3) - Linux Manuals
std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::to_bytes: std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::to_bytes
NAME
std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::to_bytes - std::wstring_convert<Codecvt,Elem,Wide_alloc,Byte_alloc>::to_bytes
Synopsis
Defined in header <locale>
byte_string to_bytes( Elem wchar ); (1)
byte_string to_bytes( const Elem* wptr ); (2)
byte_string to_bytes( const wide_string& wstr ); (3)
byte_string to_bytes( const Elem* first, const Elem* last); (4)
Performs wide to multibyte conversion, using the codecvt facet supplied at construction.
1) Converts wchar as if it was a string of length 1, to byte_string.
2) Converts the null-terminated wide character sequence beginning at the wide character pointed to by wptr, to byte_string.
3) Converts the wide string str to byte_string.
4) Converts the wide character sequence [first, last) to byte_string.
In all cases, the conversion begins in initial shift state, unless non-initial starting state was provided to this wstring_convert constructor. The number of characters converted and the final value of the conversion state are remembered and can be accessed with state() and converted()
Return value
A byte_string object containing the results of the wide to multibyte conversion. If the conversion failed and there was a user-supplied byte-error string provided to the constructor of this wstring_convert, returns that byte-error string.
Exceptions
If this wstring_convert object was constructed without a user-supplied byte-error string, throws std::range_error on conversion failure.
Example
// Run this code
Output:
See also
from_bytes (public member function)
wcsrtombs (function)
do_out converts a string from internT to externT, such as when writing to file
[virtual]