|
2023 | 2023 | Equivalent to: \tcode{return visit(std::forward<Visitor>(vis), arg.value);}
|
2024 | 2024 | \end{itemdescr}
|
2025 | 2025 |
|
2026 |
| -\rSec1[depr.locale.stdcvt]{Deprecated standard code conversion facets} |
2027 |
| - |
2028 |
| -\rSec2[depr.locale.stdcvt.general]{General} |
2029 |
| - |
2030 |
| -\pnum |
2031 |
| -The header \libheaderdef{codecvt} provides |
2032 |
| -code conversion facets for various character encodings. |
2033 |
| - |
2034 |
| -\rSec2[depr.codecvt.syn]{Header \tcode{<codecvt>} synopsis} |
2035 |
| - |
2036 |
| -\indexlibraryglobal{codecvt_mode}% |
2037 |
| -\indexlibraryglobal{codecvt_utf8}% |
2038 |
| -\indexlibraryglobal{codecvt_utf16}% |
2039 |
| -\indexlibraryglobal{codecvt_utf8_utf16}% |
2040 |
| -\begin{codeblock} |
2041 |
| -namespace std { |
2042 |
| - enum codecvt_mode { |
2043 |
| - consume_header = 4, |
2044 |
| - generate_header = 2, |
2045 |
| - little_endian = 1 |
2046 |
| - }; |
2047 |
| - |
2048 |
| - template<class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0> |
2049 |
| - class codecvt_utf8 : public codecvt<Elem, char, mbstate_t> { |
2050 |
| - public: |
2051 |
| - explicit codecvt_utf8(size_t refs = 0); |
2052 |
| - ~codecvt_utf8(); |
2053 |
| - }; |
2054 |
| - |
2055 |
| - template<class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0> |
2056 |
| - class codecvt_utf16 : public codecvt<Elem, char, mbstate_t> { |
2057 |
| - public: |
2058 |
| - explicit codecvt_utf16(size_t refs = 0); |
2059 |
| - ~codecvt_utf16(); |
2060 |
| - }; |
2061 |
| - |
2062 |
| - template<class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0> |
2063 |
| - class codecvt_utf8_utf16 : public codecvt<Elem, char, mbstate_t> { |
2064 |
| - public: |
2065 |
| - explicit codecvt_utf8_utf16(size_t refs = 0); |
2066 |
| - ~codecvt_utf8_utf16(); |
2067 |
| - }; |
2068 |
| -} |
2069 |
| -\end{codeblock} |
2070 |
| - |
2071 |
| -\rSec2[depr.locale.stdcvt.req]{Requirements} |
2072 |
| - |
2073 |
| -\pnum |
2074 |
| -For each of the three code conversion facets \tcode{codecvt_utf8}, |
2075 |
| -\tcode{codecvt_utf16}, and \tcode{codecvt_utf8_utf16}: |
2076 |
| -\begin{itemize} |
2077 |
| -\item |
2078 |
| - \tcode{Elem} is one of |
2079 |
| - \keyword{wchar_t}, \keyword{char16_t}, or \keyword{char32_t}. |
2080 |
| -\item |
2081 |
| - \tcode{Maxcode} is the largest value of \tcode{Elem} |
2082 |
| - converted to \tcode{\keyword{unsigned} \keyword{long}} |
2083 |
| - that the facet |
2084 |
| - will read or write without reporting a conversion error. |
2085 |
| -\item |
2086 |
| - If \tcode{(Mode \& consume_header)}, the facet shall consume an |
2087 |
| - initial header sequence, if present, when reading a multibyte sequence |
2088 |
| - to determine the endianness of the subsequent multibyte sequence to be read. |
2089 |
| -\item |
2090 |
| - If \tcode{(Mode \& generate_header)}, the facet shall generate an |
2091 |
| - initial header sequence when writing a multibyte sequence to advertise |
2092 |
| - the endianness of the subsequent multibyte sequence to be written. |
2093 |
| -\item |
2094 |
| - If \tcode{(Mode \& little_endian)}, the facet shall generate a |
2095 |
| - multibyte sequence in little-endian order, |
2096 |
| - as opposed to the default big-endian order. |
2097 |
| -\item |
2098 |
| - UCS-2 is the same encoding as UTF-16, |
2099 |
| - except that it encodes scalar values in the range |
2100 |
| - \ucode{0000}--\ucode{ffff} (Basic Multilingual Plane) only. |
2101 |
| -\end{itemize} |
2102 |
| - |
2103 |
| -\pnum |
2104 |
| -\indextext{UTF-8}% |
2105 |
| -\indextext{UCS-2}% |
2106 |
| -\indextext{UTF-32}% |
2107 |
| -For the facet \tcode{codecvt_utf8}\indexlibraryglobal{codecvt_utf8}: |
2108 |
| -\begin{itemize} |
2109 |
| -\item |
2110 |
| - The facet shall convert between UTF-8 multibyte sequences |
2111 |
| - and UCS-2 or UTF-32 (depending on the size of \tcode{Elem}). |
2112 |
| -\item |
2113 |
| - Endianness shall not affect how multibyte sequences are read or written. |
2114 |
| -\item |
2115 |
| - The multibyte sequences may be written as either a text or a binary file. |
2116 |
| -\end{itemize} |
2117 |
| - |
2118 |
| -\pnum |
2119 |
| -\indextext{UTF-16}% |
2120 |
| -\indextext{UCS-2}% |
2121 |
| -\indextext{UTF-32}% |
2122 |
| -For the facet \tcode{codecvt_utf16}\indexlibraryglobal{codecvt_utf16}: |
2123 |
| -\begin{itemize} |
2124 |
| -\item |
2125 |
| - The facet shall convert between UTF-16 multibyte sequences |
2126 |
| - and UCS-2 or UTF-32 (depending on the size of \tcode{Elem}). |
2127 |
| -\item |
2128 |
| - Multibyte sequences shall be read or written |
2129 |
| - according to the \tcode{Mode} flag, as set out above. |
2130 |
| -\item |
2131 |
| - The multibyte sequences may be written only as a binary file. |
2132 |
| - Attempting to write to a text file produces undefined behavior. |
2133 |
| -\end{itemize} |
2134 |
| - |
2135 |
| -\pnum |
2136 |
| -\indextext{UTF-8}% |
2137 |
| -\indextext{UTF-16}% |
2138 |
| -For the facet \tcode{codecvt_utf8_utf16}\indexlibraryglobal{codecvt_utf8_utf16}: |
2139 |
| -\begin{itemize} |
2140 |
| -\item |
2141 |
| - The facet shall convert between UTF-8 multibyte sequences |
2142 |
| - and UTF-16 (one or two 16-bit codes) within the program. |
2143 |
| -\item |
2144 |
| - Endianness shall not affect how multibyte sequences are read or written. |
2145 |
| -\item |
2146 |
| - The multibyte sequences may be written as either a text or a binary file. |
2147 |
| -\end{itemize} |
2148 |
| - |
2149 | 2026 | \rSec1[depr.conversions]{Deprecated convenience conversion interfaces}
|
2150 | 2027 |
|
2151 | 2028 | \rSec2[depr.conversions.general]{General}
|
|
2174 | 2051 | (like class template \tcode{codecvt}) to perform the conversions, without
|
2175 | 2052 | affecting any streams or locales.
|
2176 | 2053 | \begin{example}
|
2177 |
| -If you want to use the code |
2178 |
| -conversion facet \tcode{codecvt_utf8} to output to \tcode{cout} a UTF-8 |
| 2054 | +If you want to use a code |
| 2055 | +conversion facet, \tcode{codecvt_for_utf8}, to output to \tcode{cout} a UTF-8 |
2179 | 2056 | multibyte sequence corresponding to a wide string, but you don't want to
|
2180 | 2057 | alter the locale for \tcode{cout}, you can write something like:
|
2181 | 2058 | \begin{codeblock}
|
2182 |
| -std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv; |
| 2059 | +std::wstring_convert<codecvt_for_utf8<wchar_t>> myconv; |
2183 | 2060 | std::string mbstring = myconv.to_bytes(L"Hello\n");
|
2184 | 2061 | std::cout << mbstring;
|
2185 | 2062 | \end{codeblock}
|
|
0 commit comments