Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | locale
m (own sidebar)
m (Text replace - "{{mark c++11 feature}}" to "{{mark since c++11}}")
Line 3: Line 3:
 
{{ddcl list begin}}
 
{{ddcl list begin}}
 
{{ddcl list header | locale}}
 
{{ddcl list header | locale}}
{{ddcl list item | notes={{mark c++11 feature}} | 1=
+
{{ddcl list item | notes={{mark since c++11}} | 1=
 
template< class Codecvt,
 
template< class Codecvt,
 
           class Elem = wchar_t,
 
           class Elem = wchar_t,

Revision as of 14:52, 24 December 2011

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 Template:cpp performs conversions between byte string Template:cpp and wide string Template:cpp, using an individual code conversion facet Codecvt. Template:cpp assumes ownership of the conversion facet, and cannot use a facet managed by a locale. The standard facets suitable for use with Template:cpp are Template:cpp for UTF-8/UCS2 and UTF-8/UCS4 conversions and Template:cpp for UTF-8/UTF-16 conversions.

Contents

Member types

Template:tdcl list begin Template:tdcl list hitem Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list end

Member functions

constructs a new wstring_convert
(public member function)
destructs the wstring_convert and its conversion facet
(public member function)
converts a byte string into a wide string
(public member function)
converts a wide string into a byte string
(public member function)
returns the number of input characters successfully converted
(public member function)
returns the current shift state
(public member function)

Example

Template:example cpp

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