Espaces de noms
Variantes
Affichages
Actions

std::codecvt::out, std::codecvt::do_out

De cppreference.com
< cpp‎ | locale‎ | codecvt

 
 
Bibliothèque localisations
Locales et facettes
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
Classification des caractères
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversions
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classes de facettes catégorie de base
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Catégories de facettes
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Spécifique aux paramètres régionaux facettes
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Facettes de conversion de code
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8 (C++11)
codecvt_utf16 (C++11)
C locale
Original:
C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
 
Defined in header <locale>
public:

result out( stateT& state,
            const internT* from,
            const internT* from_end,
            const internT*& from_next,
            externT* to,
            externT* to_end,

            externT*& to_next ) const;
(1)
protected:

result do_out( stateT& state,
               const internT* from,
               const internT* from_end,
               const internT*& from_next,
               externT* to,
               externT* to_end,

               externT*& to_next ) const;
(2)
1)
fonction de membre du public, appelle le do_out fonction membre de la classe la plus dérivée .
Original:
public member function, calls the member function do_out 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)
Si cette facette codecvt définit une conversion, convertit les caractères internes de la [from, from_end) plage source à caractères extérieurs, de placer les résultats dans les emplacements suivants à partir de to. Convertit pas plus de caractères from_end - from internes et écrit plus de caractères to_end - to externes. 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 internal characters from the source range [from, from_end) to external characters, placing the results in the subsequent locations starting at to. Converts no more than from_end - from internal characters and writes no more than to_end - to external 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.
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.

Sommaire

[modifier] 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.
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::noconv
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> always returns std::codecvt_base::noconv
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] 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.
Alors que codecvt soutient N: M conversions (par exemple UTF-16 en UTF-8, où deux personnages interne peut être nécessaire de décider ce que les caractères externes à la sortie), std::basic_filebuf ne pouvez utiliser facettes qui définissent un codecvt 1: la conversion N, c'est à dire qu'il doit être capable de traiter un caractère interne à une époque où l'écriture dans un fichier .
Original:
While codecvt supports N:M conversions (e.g. UTF-16 to UTF-8, where two internal characters may be necessary to decide what external characters to output), std::basic_filebuf can only use codecvt facets that define a 1:N conversion, that is it must be able to process one internal character at a time when writing to a file.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Lorsque vous effectuez N: M conversions, cette fonction peut retourner std::codecvt_base::partial après avoir consommé tous les caractères d'origine (). Cela signifie qu'un caractère interne est nécessaire pour effectuer la conversion (par exemple lors de la conversion UTF-16 en UTF-8, si le dernier caractère dans le tampon source est un substitut étendu) .
Original:
When performing N:M conversions, this function may return std::codecvt_base::partial after consuming all source characters (). This means that another internal character is needed to complete the conversion (e.g. when converting UTF-16 to UTF-8, if the last character in the source buffer is a high surrogate).
The text has been machine-translated via Google Translate.
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::wcsrtombs, et est donc mis à jour pour refléter l'état de décalage après le dernier caractère converti avec succès, 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::wcsrtombs, and is therefore updated to reflect the shift state after the last successfully converted 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.

[modifier] 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::wstring internal = L"z\u00df\u6c34\U0001d10b"; // L"zß水𝄋"
 
    // note that the following can be done with wstring_convert
    std::mbstate_t mb = std::mbstate_t(); // initial shift state
    std::string external(internal.size() * f.max_length(), '\0'); 
    const wchar_t* from_next;
    char* to_next;
    f.out(mb, &internal[0], &internal[internal.size()], from_next,
              &external[0], &external[external.size()], to_next);
    // error checking skipped for brevity
    external.resize(to_next - &external[0]);
 
    std::cout << "The string in narrow multibyte encoding: " << external << '\n';
}

Résultat :

The string in narrow multibyte encoding: zß水𝄋

[modifier] 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.
]
écrit des caractères dans le fichier associé à partir de la zone de mise
Original:
writes characters to the associated file from the put area
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) [edit]
convertit une chaîne de large dans une chaîne d'octets
Original:
converts a wide string into a byte 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) [edit]
convertit une chaîne large de chaîne de caractères multi-octets étroite, état donné
Original:
converts a wide string to narrow multibyte character 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) [edit]
[
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 Externt à internt, comme lors de la lecture du fichier
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.

(fonction membre virtuelle protégée) [edit]