Namensräume
Varianten
Aktionen

std::wcrtomb

Aus cppreference.com
< cpp‎ | string‎ | multibyte

 
 
Strings Bibliothek
Null-terminierte Strings
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Byte-Strings
Multibyte-Strings
Wide Strings
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
Nullterminierten Multibyte Strings
Wide / Multibyte Konvertierungen
Original:
Wide/multibyte conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbsinit
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbstate_t
 
Defined in header <cwchar>
std::size_t wcrtomb( char* s, wchar_t wc, std::mbstate_t* ps );
Konvertiert eine breite Charakter seiner schmalen Multibyte-Darstellung .
Original:
Converts a wide character to its narrow multibyte representation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn s nicht ein NULL-Zeiger, bestimmt die Funktion die Anzahl der Bytes notwendig, die Multibyte-Zeichen Darstellung wc (einschließlich etwaiger Schichtfolgen) zu speichern, und speichert die Multibyte-Zeichen Darstellung in der Zeichen-Array, dessen erstes Element wird durch s hingewiesen. An den meisten MB_CUR_MAX bytes kann mit dieser Funktion geschrieben werden .
Original:
If s is not a null pointer, the function determines the number of bytes necessary to store the multibyte character representation of wc (including any shift sequences), and stores the multibyte character representation in the character array whose first element is pointed to by s. At most MB_CUR_MAX bytes can be written by this function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn s ein NULL-Zeiger ist, ist der Anruf entspricht std::wcrtomb(buf, L'\0', ps) für einige interne Puffer buf .
Original:
If s is a null pointer, the call is equivalent to std::wcrtomb(buf, L'\0', ps) for some internal buffer buf.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn wc ist die null-Zeichen L'\0', wird ein Null-Byte gespeichert, vorangestellt jedem Schaltvorgang notwendig, um die anfängliche Verschiebung Staat und die Umwandlung Zustandsparameter *ps wird aktualisiert, um den ursprünglichen Schaltzustand stellen wiederherzustellen .
Original:
If wc is the null wide character L'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter *ps is updated to represent the initial shift state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Inhaltsverzeichnis

[Bearbeiten] Parameter

s -
Zeiger auf schmalen Zeichen-Array, wo die Multibyte-Zeichen gespeichert werden
Original:
pointer to narrow character array where the multibyte character will be stored
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wc -
die breite Zeichen konvertieren
Original:
the wide character to convert
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ps -
Zeiger auf die Umwandlung state-Objekt verwendet werden, wenn der Interpretation der Multibyte-String
Original:
pointer to the conversion state object used when interpreting the multibyte string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Rückgabewert

Bei Erfolg gibt die Anzahl der Bytes (einschließlich etwaiger Schichtfolgen) geschrieben, um die Zeichen-Array, dessen erstes Element wird durch s hingewiesen .
Original:
On success, returns the number of bytes (including any shift sequences) written to the character array whose first element is pointed to by s.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Bei einem Fehler (wenn wc ist keine gültige wide character), kehrt static_cast<std::size_t>(-1), speichert EILSEQ in errno und verlässt *ps in unbestimmten Zustand .
Original:
On failure (if wc is not a valid wide character), returns static_cast<std::size_t>(-1), stores EILSEQ in errno, and leaves *ps in unspecified state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Beispiel

#include <iostream>
#include <clocale>
#include <string>
#include <cwchar>
 
void print_wide(const std::wstring& wstr)
{
    std::mbstate_t state = std::mbstate_t();
    for(wchar_t wc : wstr) {
        std::string mb(MB_CUR_MAX, '\0');
        int ret = std::wcrtomb(&mb[0], wc, &state);
        std::cout << "multibyte char " << mb << " is " << ret << " bytes\n";
    }
}
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    std::wstring wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋"
    print_wide(wstr);
}

Output:

multibyte char z is 1 bytes
multibyte char ß is 2 bytes
multibyte char 水 is 3 bytes
multibyte char 𝄋 is 4 bytes

[Bearbeiten] Siehe auch

ein breites Charakter seiner Multibyte-Darstellung
Original:
converts a wide character to its multibyte representation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktion) [edit]
wandelt die nächsten Multibyte Zeichen-Zeichen, gegebenen Zustand
Original:
converts the next multibyte character to wide character, given state
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktion) [edit]
[virtuell]
wandelt eine Zeichenkette aus Internt zu externT, wie beim Schreiben in eine Datei
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.

(virtuellen geschützten Member-Funktion of std::codecvt) [edit]
C documentation for wcrtomb