CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 23 Jul 2025 19:20:26 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/locale/codecvt/
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Jul 2025 19:20:26 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"a364-dIEzWY8hDLKQ18C8UvXSlq8BcqE"
Content-Encoding: gzip
The codecvt standard facet translates between two different character encodings: an internal character type (generally some type of wide character) and an external character type (generally representing a multibyte sequence).
The codecvt class template has a protected destructor: Programs shall only construct objects of derived classes, or use those installed in locale objects (through use_facet).
All standard locale objects support at least the following facet instantiations of the codecvt class template (as part of the ctype category):
Header
The class also inherits codecvt_base::result, which is used as the return type for members in, out and unshift.
The class also contains a public static constant of type locale::id, that uniquely identifies facets with codecvt semantics.
Along with the class destructor:
The class contains a public static constant of type locale::id that uniquely identifies facets with codecvt semantics.
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<locale>
- has_facet
- locale
- use_facet
-
wbuffer_convertC++11
-
wstring_convertC++11
functions
standard facets
codecvt
- codecvt::codecvt
public member functions
protected members
class template
<locale>
std::codecvt
template <class internT, class externT, class stateT> class codecvt;
Convert codeset facet
- locale::facetcodecvt_base
- codecvt
The codecvt standard facet translates between two different character encodings: an internal character type (generally some type of wide character) and an external character type (generally representing a multibyte sequence).
The codecvt class template has a protected destructor: Programs shall only construct objects of derived classes, or use those installed in locale objects (through use_facet).
All standard locale objects support at least the following facet instantiations of the codecvt class template (as part of the ctype category):
facets in locale objects | description |
---|---|
codecvt<char,char,mbstate_t> | performs no conversion |
codecvt<wchar_t,char,mbstate_t> | converts between native wide and narrow character sets |
facets in locale objects | description |
---|---|
codecvt<char,char,mbstate_t> | performs no conversion |
codecvt<wchar_t,char,mbstate_t> | converts between native wide and narrow character sets |
codecvt<char16_t,char,mbstate_t> | converts between UTF16 and UTF8 encodings |
codecvt<char32_t,char,mbstate_t> | converts between UTF32 and UTF8 encodings |
Header
<codecvt>
defines additional stand-alone facet objects derived from codecvt (for more info, see header <codecvt>
).Template parameters
- internT
- Internal character type: Typically, this is the wide character type.
Aliased as member intern_type.
- externT
- External character type: Typically, this is the multi-byte type.
Aliased as member extern_type.
- stateT
- A state type: Typically, this is an object able to keep track of the state of the conversion, such as mbstate_t (or, more generically,
char_traits<externT>::state_type
).
Aliased as member state_type.
Member types
member type | definition | description |
---|---|---|
intern_type | The first template parameter (internT) | Internal character type |
extern_type | The second template parameter (externT) | External character type |
state_type | The third template parameter (stateT) | State type |
Member constants
The following member constants are inherited from codecvt_base (as labels ofenum
type codecvt_base::result); They are used as return values by certain member functions.member constant | type | value | description |
---|---|---|---|
ok | codecvt_base::result | 0 | Conversion successful |
partial | codecvt_base::result | 1 | Partial conversion |
error | codecvt_base::result | 2 | Conversion error |
noconv | codecvt_base::result | 3 | No conversion |
The class also contains a public static constant of type locale::id, that uniquely identifies facets with codecvt semantics.
Public member functions
- (constructor)
- codecvt constructor (public member function)
Conversion functions
- in
- Translate in characters (public member function)
- out
- Translate out characters (public member function)
- unshift
- Unshift translation state (public member function)
Character encoding properties
- always_noconv
- Return noconv characteristics (public member function)
- encoding
- Return encoding width (public member function)
- length
- Return length of translated sequence (public member function)
- max_length
- Return max length of one character (public member function)
Virtual protected member functions
The class defines the virtual protected members which implement the behavior by default of their respective public member functions:- do_always_noconv
- Return noconv characteristics [virtual] (protected virtual member function)
- do_encoding
- Return encoding width [virtual] (protected virtual member function)
- do_in
- Translate in characters [virtual] (protected virtual member function)
- do_length
- Return length of translated sequence [virtual] (public member function)
- do_max_length
- Return max length of one character [virtual] (protected virtual member function)
- do_out
- Translate out characters [virtual] (protected virtual member function)
- do_unshift
- Unshift translation state [virtual] (protected virtual member function)
Along with the class destructor:
- (destructor)
- codecvt destructor (protected member function)
Specializations
At least the following specializations of this template are provided in all library implementations:specialization |
---|
codecvt<char,char,mbstate_t> |
codecvt<wchar_t,char,mbstate_t> |
specialization |
---|
codecvt<char,char,mbstate_t> |
codecvt<wchar_t,char,mbstate_t> |
codecvt<char16_t,char,mbstate_t> |
codecvt<char32_t,char,mbstate_t> |
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us