Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/locale/wstring convert"

From cppreference.com
< cpp‎ | locale
m (Text replace - "{{cpp|" to "{{c|")
m (Text replace - "{{tdcl list begin" to "{{dcl list begin")
Line 15: Line 15:
  
 
===Member types===
 
===Member types===
{{tdcl list begin}}
+
{{dcl list begin}}
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list item | {{tt|byte_string}} | {{tt|std::basic_string<char, char_traits<char>, Byte_alloc>}}}}
 
{{tdcl list item | {{tt|byte_string}} | {{tt|std::basic_string<char, char_traits<char>, Byte_alloc>}}}}

Revision as of 01:17, 12 June 2012

Template:cpp/locale/wstring convert/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <locale>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td >
template< class Codecvt,

          class Elem = wchar_t,
          class Wide_alloc = std::allocator<Elem>,
          class Byte_alloc = std::allocator<char> >

class wstring_convert;
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

Class template std::wstring_convert performs conversions between byte string std::string and wide string std::basic_string<Elem>, using an individual code conversion facet Codecvt. std::wstring_convert assumes ownership of the conversion facet, and cannot use a facet managed by a locale. The standard facets suitable for use with std::wstring_convert are std::codecvt_utf8 for UTF-8/UCS2 and UTF-8/UCS4 conversions and std::codecvt_utf8_utf16 for UTF-8/UTF-16 conversions.

Member types

Template:tdcl list hitemTemplate:tdcl list itemTemplate:tdcl list itemTemplate:tdcl list itemTemplate:tdcl list itemTemplate:tdcl list end

Member functions

Template:cpp/locale/wstring convert/dcl list wstring convertTemplate:cpp/locale/wstring convert/dcl list ~wstring convertTemplate:cpp/locale/wstring convert/dcl list from bytesTemplate:cpp/locale/wstring convert/dcl list to bytesTemplate:cpp/locale/wstring convert/dcl list convertedTemplate:cpp/locale/wstring convert/dcl list state

See also

Character
conversions
locale-defined multibyte
(UTF-8, GB18030)
UTF-8
UTF-16
UTF-16 mbrtoc16 / c16rtomb (with C11's DR488)

codecvt<char16_t,char,mbstate_t>
codecvt_utf8_utf16<char16_t>
codecvt_utf8_utf16<char32_t>
codecvt_utf8_utf16<wchar_t>

N/A
UCS-2 c16rtomb (without C11's DR488) codecvt_utf8<char16_t> codecvt_utf16<char16_t>
UTF-32

mbrtoc32 / c32rtomb

codecvt<char32_t,char,mbstate_t>
codecvt_utf8<char32_t>

codecvt_utf16<char32_t>

system wchar_t:

UTF-32 (non-Windows)
UCS-2 (Windows)

mbsrtowcs / wcsrtombs
use_facet<codecvt
<wchar_t,char,mbstate_t>>(locale)

codecvt_utf8<wchar_t> codecvt_utf16<wchar_t>
Template:cpp/locale/dcl list wbuffer convertTemplate:cpp/locale/dcl list codecvt utf8Template:cpp/locale/dcl list codecvt utf8 utf16