std::codecvt::in, std::codecvt::do_in
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <locale>
|
||
public: result in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next, internT* to, internT* to_end, internT*& to_next ) const; |
(1) | |
protected: result do_in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next, internT* to, internT* to_end, internT*& to_next ) const; |
(2) | |
1)
fonction de membre du public, appelle le
do_in fonction membre de la classe la plus dérivée .Original:
public member function, calls the member function
do_in 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.
You can help to correct and verify the translation. Click here for instructions.
2)
Si cette facette
codecvt définit une conversion, convertit les caractères extérieurs de la plage source [from, from_end) de caractères internes, placer les résultats dans les emplacements suivants à partir de to. Convertit pas plus de caractères from_end - from externes et écrit plus de caractères to_end - to internes. Feuilles from_next et to_next pointant un au-delà du dernier élément a réussi à convertir .Original:
If this
codecvt facet defines a conversion, translates the external characters from the source range [from, from_end) to internal characters, placing the results in the subsequent locations starting at to. Converts no more than from_end - from external characters and writes no more than to_end - to internal characters. Leaves from_next and to_next pointing one beyond the last element successfully converted.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Si cette facette
codecvt ne définit pas une conversion, pas de caractères sont converties. to_next est réglée pour être égale à to, state est inchangé, et est retourné std::codecvt_base::noconv .Original:
If this
codecvt facet does not define a conversion, no characters are converted. to_next is set to be equal to to, state is unchanged, and std::codecvt_base::noconv is returned.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Retourne la valeur
Une valeur de std::codecvt_base::result type, qui indique l'état de réussite comme suit:
Original:
A value of type std::codecvt_base::result, indicating the success status as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
ok
|
conversion terminée
Original: conversion completed The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
partial
|
pas assez d'espace dans la mémoire tampon de sortie ou à la fin inattendue du tampon source
Original: not enough space in the output buffer or unexpected end of source buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
error
|
rencontré un personnage qui n'a pas pu être convertie
Original: encountered a character that could not be converted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
noconv
|
cette facette est non-conversion, aucune sortie écrite
Original: this facet is non-converting, no output written The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
La spécialisation non-conversion
std::codecvt<char, char, std::mbstate_t> renvoie toujours std::codecvt_base::noconvOriginal:
The non-converting specialization
std::codecvt<char, char, std::mbstate_t> always returns std::codecvt_base::noconvThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Notes
Exige que
from <= from_end && to <= to_end et qui supporte state représentant l'état initial ou obtenues en convertissant les caractères précédents dans la séquence .Original:
Requires that
from <= from_end && to <= to_end and that state either representing the initial shift state or obtained by converting the preceding characters in the sequence.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
L'effet sur
state est délibérément non précisée. Dans facettes standards, il est utilisé pour maintenir un état de décalage, comme lors de l'appel std::mbsrtowcs, et est donc mis à jour pour refléter l'état de conversion après le dernier caractère externe de traitement, mais une facette définie par l'utilisateur est libre de l'utiliser pour maintenir n'importe quel autre état, par exemple, compter le nombre de caractères spéciaux rencontrés .Original:
The effect on
state is deliberately unspecified. In standard facets, it is used to maintain shift state like when calling std::mbsrtowcs, and is therefore updated to reflect the conversion state after the last processed external character, but a user-defined facet is free to use it to maintain any other state, e.g. count the number of special characters encountered.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Exemple
#include <iostream>
#include <string>
#include <locale>
int main()
{
std::locale::global(std::locale("en_US.utf8"));
auto& f = std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(std::locale());
std::string external = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
// or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
// note that the following can be done with wstring_convert
std::mbstate_t mb = std::mbstate_t(); // initial shift state
std::wstring internal(external.size(), '\0');
const char* from_next;
wchar_t* to_next;
f.in(mb, &external[0], &external[external.size()], from_next,
&internal[0], &internal[internal.size()], to_next);
// error checking skipped for brevity
internal.resize(to_next - &internal[0]);
std::wcout << L"The string in wide encoding: " << internal << '\n';
}
Résultat :
The string in wide encoding: zß水𝄋
Voir aussi
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
lit le fichier associé Original: reads from the associated file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protégée de std::basic_filebuf)
|
convertit une chaîne d'octets en une chaîne large Original: converts a byte string into a wide string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique de std::wstring_convert)
| |
convertit une chaîne de caractères multi-octets en une chaîne de caractère étroit de large, état donné Original: converts a narrow multibyte character string to wide string, given state The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
convertit une chaîne de Internt à Externt, comme lors de l'écriture dans un fichier Original: converts a string from internT to externT, such as when writing to file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protégée) |