Notice: Unexpected clearActionName after getActionName already called in /var/www/cppreference.com/public/includes/context/RequestContext.php on line 338
std::codecvt::length, std::codecvt::do_length - cppreference.com
close
Espacios de nombres
Variantes

std::codecvt::length, std::codecvt::do_length

De cppreference.com
(Redirigido desde «cpp/locale/codecvt/do length»)
 
 
 
 
<tbody> </tbody>
Definido en el archivo de encabezado <locale>
public: int length( stateT& state, const externT* from, const externT* from_end, std::size_t max ) const
(1)
protected: int do_length( stateT& state, const externT* from, const externT* from_end, std::size_t max ) const
(2)

1)

función miembro pública, llama a la función do_length miembro de la clase más derivada .
Original:
public member function, calls the member function do_length of the most derived class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

los intentos de convertir los caracteres externT de la matriz de caracteres definido por [from, from_end), dado state inicial estado de conversión, en la mayoría de max internT caracteres y devuelve el número de caracteres externT que dicha conversión se consumen. Modifica state como si mediante la ejecución de do_in(state, from, from_end, from, to, to+max, to) por alguna [to, to+max) búfer de salida imaginaria .
Original:
attempts to convert the externT characters from the character array defined by [from, from_end), given initial conversion state state, to at most max internT characters, and returns the number of externT characters that such conversion would consume. Modifies state as if by executing do_in(state, from, from_end, from, to, to+max, to) for some imaginary [to, to+max) output buffer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valor de retorno

El número de caracteres externT que se consumirían si se convierte en do_in() hasta que todos los personajes from_end-from fueron consumidos o max internT personajes eran productores, o un error de conversión producido .
Original:
The number of externT characters that would be consumed if converted by do_in() until either all from_end-from characters were consumed or max internT characters were producer, or a conversion error occurred.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
La especialización no convertir std::codecvt<char, char, std::mbstate_t> vuelve std::min(max, from_end-from)
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns std::min(max, from_end-from)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Ejemplo

#include <locale>
#include <string>
#include <iostream>
int main()
{
    //  narrow multibyte encoding
    std::string s = "z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
                      // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
    std::mbstate_t mb = std::mbstate_t();
    std::cout << "Only the first " <<
              std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("en_US.utf8")
              ).length(mb, &s[0], &s[s.size()], 2)
              << " bytes out of " << s.size() << " would be consumed "
                 " to produce the first 2 characters\n";
}

Salida:

Only the first 3 bytes out of 10 would be consumed to produce the first 2 characters

Ver también

[virtual]
convierte una cadena de externT a internt, como cuando al leer el archivo
Original:
converts a string from externT to internT, such as when reading from file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función miembro virtual protegida) [editar]