CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 29 Jul 2025 12:53:29 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/locale/codecvt/length/
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 29 Jul 2025 12:53:29 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"91c7-q5frsu57sIXlQ3l6f9LNYKrBF7M"
Content-Encoding: gzip
Returns the number of external characters in the range [from,from_end) that could be translated into at maximum of max internal characters, as if applying codecvt::in.
state is also updated as if codecvt::in was called for a buffer of max internal characters.
Internally, this function simply calls the virtual protected member do_length, which behaves as described above by default.
Output:
The argument passed as state is modified.
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::length
int length (state_type& state, const extern_type* from, const extern_type* from_end, size_t max) const;
Return length of translated sequence
state is also updated as if codecvt::in was called for a buffer of max internal characters.
Internally, this function simply calls the virtual protected member do_length, 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 are considered valid characters and do not stop the function from proceeding until from_end.
Member type extern_type is the facet's external character type (defined as an alias of codecvt's second template parameter, exnternT).
- max
- Maximum length of the translated sequence (in terms of internal characters).
size_t is an unsigned integral type.
Return value
The length of the sequence of characters, in terms of translated internal characters.Example
|
|
Output:
abcdefghijklmnopqrstuvwxyz |
Data races
The facet object and up to all the characters in the range[from,from_end)
are accessed.The argument passed as state is modified.
Exception safety
If an exception is thrown, there are no changes in the facet object (although state may have changed).See also
- codecvt::in
- Translate in characters (public member function)
- codecvt::max_length
- Return max length of one character (public member function)
- codecvt::do_length
- Return length of translated sequence [virtual] (public 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