CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 28 Jul 2025 01:54:05 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/locale/codecvt/out/
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 28 Jul 2025 01:54:05 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"9eb9-5Ol1LM40skt8Q70jaofiBRNX6aM"
Content-Encoding: gzip
Translates sequentially the characters in the range
This member function translates from intern type to extern type, which typically is a wide character-to-multibyte conversion (see member in for the inverse operation).
The function stops converting as soon as it fails to convert a character, or once from_end is reached and its character is successfully converted.
The return value, along with the values that from_next and to_next have after the call, can be used to evaluate the success and state of the operation.
Internally, this function simply calls the virtual protected member do_out, which behaves as described above by default.
Possible output:
The arguments state, from_next and to_next, along with up to all the characters in the range
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
public member function
<locale>
std::codecvt::out
result out (state_type& state, const intern_type* from, const intern_type* from_end, const intern_type*& from_next, extern_type* to, extern_type* to_limit, extern_type*& to_next) const;
Translate out characters
[from,from_end)
and places them in the range starting at to. It does not attempt to store more characters once to_limit is reached.This member function translates from intern type to extern type, which typically is a wide character-to-multibyte conversion (see member in for the inverse operation).
The function stops converting as soon as it fails to convert a character, or once from_end is reached and its character is successfully converted.
The return value, along with the values that from_next and to_next have after the call, can be used to evaluate the success and state of the operation.
Internally, this function simply calls the virtual protected member do_out, which behaves as described above by default.
Parameters
- state
- A state object, as required by the facet instantiation.
Typically, this is an object of type mbstate_t, able to keep track of the shift state of a multibyte character conversion.
Member type state_type is the facet's state type (defined as an alias of codecvt's third template parameter, stateT).
- from, from_end
- Pointer to the initial and final characters of the source sequence. The range used is
[from,from_end)
, which contains all the characters between from and from_end, including the character pointed by from but not the character pointed by from_end.
Note that null characters (if any) are also translated, and the function proceeds beyond them until from_end.
Member type intern_type is the facet's internal character type (defined as an alias of codecvt's first template parameter, internT).
- from_next
- Pointer able to point to an element in the above range. Once the function returns, this object points to the element in the source range beyond the last one successfully translated.
- to, to_limit
- Pointer to the initial and final characters of the destination sequence. The range used is, at most,
[to,to_limit)
, which contains all the characters between to and to_limit, including the character pointed by to but not the character pointed by to_limit.
A translation does not necessarily need to fill up the range to its limit, and may also exhaust it before finishing.
No additional null character is automatically appended (other than those translated from the source sequence).
Member type extern_type is the facet's external character type (defined as an alias of codecvt's second template parameter, externT).
- to_next
- Pointer able to point to an element in the above range. Once the function returns, this object points to the element in the destination range beyond the last one successfully translated.
Return value
A value of type codecvt_base::result, with the following possible values:member constant | int value | result |
---|---|---|
ok | 0 | Conversion successful: all characters were translated. |
partial | 1 | Partial conversion: either the destination sequence [to,to_limit) is not long enough, or from_end has been reached but additional source characters are needed to complete a destination character.To reset the shift state, see codecvt::unshift. All previous characters have been successfully translated. |
error | 2 | Conversion error: No valid conversion existed for the character pointed by from_next. All previous characters have been successfully translated. |
noconv | 3 | No conversion: The source and destination character types (intern_type and extern_type) are the same. No conversion attempted: the source characters have been copied to the destination. |
Example
|
|
Possible output:
Enter sentence: Test sentence Translation successful: Test sentence |
Data races
The facet object and up to all the characters in the range[from,from_end)
are accessed.The arguments state, from_next and to_next, along with up to all the characters in the range
[to,to_limit)
are modified.Exception safety
If an exception is thrown, there are no changes in the facet object, although characters in the destination range and arguments passed by reference may have been affected.See also
- codecvt::in
- Translate in characters (public member function)
- codecvt::do_out
- Translate out characters [virtual] (protected virtual member function)
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