std::wcstombs
Aus 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. |
definiert in Header <cstdlib>
|
||
std::size_t wcstombs( char* dst, const wchar_t* src, std::size_t len) |
||
Konvertiert eine Folge von breiten Zeichen aus dem Array, dessen erstes Element wird durch
src
seiner schmalen Multibyte-Darstellung, die in der ursprünglichen Schaltzustand beginnt hingewiesen. Umgerechnet Zeichen werden in den aufeinander folgenden Elementen der char Array, auf das dst
gespeichert. Nicht mehr als len
Bytes an das Ziel-Array geschrieben .Original:
Converts a sequence of wide characters from the array whose first element is pointed to by
src
to its narrow multibyte representation that begins in the initial shift state. Converted characters are stored in the successive elements of the char array pointed to by dst
. No more than len
bytes are written to the destination array.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.
Jedes Zeichen wird, als ob durch einen Aufruf std::wctomb umgewandelt, außer dass die wctomb Bekehrung Staat nicht betroffen ist. Die Umwandlung gestoppt, wenn:
Original:
Each character is converted as if by a call to std::wctomb, except that the wctomb's conversion state is unaffected. The conversion stops if:
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.
- Das Null-Zeichen wurde umgewandelt und gespeichert .Original:The null character was converted and stored.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - A wchar_t wurde festgestellt, dass nicht zu einem gültigen Zeichen in der aktuellen C locale entsprechen .Original:A wchar_t was found that does not correspond to a valid character in the current C locale.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Der nächste Multibyte-Zeichen gespeichert werden übersteigen würde
len
.Original:The next multibyte character to be stored would exceedlen
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Inhaltsverzeichnis |
[Bearbeiten] Notes
Bei den meisten Implementierungen aktualisiert diese Funktion eine globale statische Objekt vom Typ std::mbstate_t wenn es durch die Zeichenfolge verarbeitet, und kann nicht gleichzeitig von zwei Threads aufgerufen werden sollte std::wcsrtombs in solchen Fällen eingesetzt werden .
Original:
In most implementations, this function updates a global static object of type std::mbstate_t as it processes through the string, and cannot be called simultaneously by two threads, std::wcsrtombs should be used in such cases.
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.
POSIX legt eine gemeinsame Erweiterung: Wenn
dst
ein NULL-Zeiger ist, gibt diese Funktion die Anzahl der Bytes, die dst
geschrieben werden würde, wenn umgewandelt. Ein ähnliches Verhalten ist Standard für std::wcsrtombs .Original:
POSIX specifies a common extension: if
dst
is a null pointer, this function returns the number of bytes that would be written to dst
, if converted. Similar behavior is standard for std::wcsrtombs.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.
[Bearbeiten] Parameter
dst | - | 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. |
src | - | Zeiger auf das erste Element einer nullterminierten breite String zu konvertieren
Original: pointer to the first element of a null-terminated wide string to convert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
len | - | Anzahl der Byte im Array, auf das dst
Original: number of byte available in the array pointed to by dst 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, aber ohne das abschließende '\0') geschrieben, um die Zeichen-Array, dessen erstes Element wird durch
dst
hingewiesen .Original:
On success, returns the number of bytes (including any shift sequences, but excluding the terminating '\0') written to the character array whose first element is pointed to by
dst
.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.
Bei der Umwandlung Fehler (wenn ungültige Multibyte-Zeichen angetroffen wurde), gibt static_cast<std::size_t>(-1) .
Original:
On conversion error (if invalid wide character was encountered), returns static_cast<std::size_t>(-1).
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.
[Bearbeiten] Beispiel
#include <iostream> #include <clocale> #include <cstdlib> int main() { std::setlocale(LC_ALL, "en_US.utf8"); // UTF-8 narrow multibyte encoding const wchar_t* wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋" char mbstr[11]; std::wcstombs(mbstr, wstr, 11); std::cout << "multibyte string: " << mbstr << '\n'; }
Output:
multibyte string: zß水𝄋
[Bearbeiten] Siehe auch
wandelt eine breite Zeichenfolge in schmale Multibyte Zeichenkette gegebenen Zustand 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. (Funktion) | |
wandelt einen schmalen Multibyte Zeichenkette breite String Original: converts a narrow multibyte character string to wide string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktion) | |
[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 )
|
C documentation for wcstombs
|