Namensräume
Varianten

std::wctomb

Aus cppreference.com

<metanoindex/>

 
 
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
 
<tbody> </tbody>
definiert in Header <cstdlib>
int wctomb( char *s, wchar_t wc );
Konvertiert eine breite Charakter wc zur Codierung und speichert sie (einschließlich etwaiger Wechsel-Sequenzen) in der char-Arrays, deren erstes Element wird durch s wies multibyte. Nicht mehr als MB_CUR_MAX Zeichen gespeichert werden .
Original:
Converts a wide character wc to multibyte encoding and stores it (including any shift sequences) in the char array whose first element is pointed to by s. No more than MB_CUR_MAX characters are stored.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn wc das Nullzeichen ist, wird die Null-Byte, um s geschrieben vorangestellt jegliche Verschiebung notwendigen Sequenzen, um die anfängliche Verschiebung Zustand wiederherzustellen .
Original:
If wc is the null character, the null byte is written to s, preceded by any shift sequences necessary to restore 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.
Wenn s ist ein NULL-Zeiger, setzt die globale Umstellung Staat und bestimmt, ob Shift-Sequenzen verwendet werden .
Original:
If s is a null pointer, resets the global conversion state and determines whether shift sequences are used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parameter

s -
Zeiger auf den Zeichen-Array für die Ausgabe
Original:
pointer to the character array for output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wc -
Breitzeichen zu konvertieren
Original:
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.

Rückgabewert

Wenn s nicht ein NULL-Zeiger, gibt die Anzahl von Bytes, die in der Multibyte-Darstellung von enthaltenen wc oder -1 wenn wc ist kein gültiges Zeichen .
Original:
If s is not a null pointer, returns the number of bytes that are contained in the multibyte representation of wc or -1 if wc is not a valid character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn ein Null-Zeiger s ist, setzt seinen internen Zustand Umwandlung, um die anfängliche Schaltzustand und kehrt 0 repräsentieren, wenn die aktuelle Multibyte Codierung nicht zustandsabhängigen (verwendet keine Verschiebung Sequenzen) oder einen von Null verschiedenen Wert, falls der aktuelle Multibyte-Kodierung ist state-abhängige (verwendet Schichtfolgen) .
Original:
If s is a null pointer, resets its internal conversion state to represent the initial shift state and returns 0 if the current multibyte encoding is not state-dependent (does not use shift sequences) or a non-zero value if the current multibyte encoding is state-dependent (uses shift sequences).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Notes

Jeder Aufruf wctomb aktualisiert die interne globale Umstellung Zustand (ein statisches Objekt vom Typ std::mbstate_t, nur um diese Funktion bekannt). Wenn die Multibyte-Kodierung verwendet Verschiebung Staaten, ist diese Funktion nicht reentrant. In jedem Fall sollten mehrere Threads nicht nennen wctomb ohne Synchronisation: std::wcrtomb dürfen stattdessen verwendet werden .
Original:
Each call to wctomb updates the internal global conversion state (a static object of type std::mbstate_t, only known to this function). If the multibyte encoding uses shift states, this function is not reentrant. In any case, multiple threads should not call wctomb without synchronization: std::wcrtomb may be used instead.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Beispiel

#include <iostream>
#include <clocale>
#include <string>
#include <cstdlib>

void print_wide(const std::wstring& wstr)
{
    bool shifts = std::wctomb(NULL, 0); // reset the conversion state
    std::cout << "shift sequences " << (shifts ? "are" : "not" ) << " used\n";
    for (wchar_t wc : wstr) {
        std::string mb(MB_CUR_MAX, '\0');
        int ret = std::wctomb(&mb[0], wc);
        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:

shift sequences not used
multibyte char z is 1 bytes
multibyte char ß is 2 bytes
multibyte char 水 is 3 bytes
multibyte char 𝄋 is 4 bytes

Siehe auch

wandelt die nächsten Multibyte Zeichen-Zeichen
Original:
converts the next multibyte character to wide character
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 eine breite Charakter seiner Multibyte-Darstellung, gegebenen Zustand
Original:
converts a wide character to its multibyte representation, 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 wctomb