std::wcsrtombs
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. |
<metanoindex/>
<tbody> </tbody>| definiert in Header <cwchar>
|
||
std::size_t wcsrtombs( char* dst, const wchar_t** src, std::size_t len, std::mbstate_t* ps ); |
||
Konvertiert eine Folge von breiten Zeichen aus dem Array, dessen erstes Element ist, um durch
*src seiner schmalen Multibyte-Darstellung die in der Konvertierung Zustand durch *ps beschrieben beginnt hingewiesen. Wenn dst nicht null ist, umgewandelt werden Zeichen in den aufeinanderfolgenden 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 conversion state described by *ps. If dst is not null, 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::wcrtomb umgewandelt. Die Umwandlung gestoppt, wenn:
Original:
Each character is converted as if by a call to std::wcrtomb. 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.
srceingestellt ist NULL und*psstellt den ersten Schaltzustand .Original:The null character was converted and stored.srcis set to NULL and*psrepresents 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. - A
wchar_twurde festgestellt, dass nicht zu einem gültigen Zeichen in der aktuellen C locale entsprechen.srcsoll bei der ersten umgesetzten breite Zeichen zeigen .Original:Awchar_twas found that does not correspond to a valid character in the current C locale.srcis set to point at the first unconverted wide character.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - die nächste Multibyte-Zeichen gespeichert werden übersteigen würde
len.srcsoll bei der ersten umgesetzten breite Zeichen zeigen. Dieser Zustand wird nicht geprüft, obdst==NULL.Original:the next multibyte character to be stored would exceedlen.srcis set to point at the first unconverted wide character. This condition is not checked ifdst==NULL.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| dst | - | Zeiger auf schmalen Zeichen-Array, wo die Multibyte-Zeichen gespeichert werden
Original: pointer to narrow character array where the multibyte characters 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 Zeiger auf das erste Element einer nullterminierten breite String
Original: pointer to pointer to the first element of a null-terminated wide string 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 verfügbaren Bytes im Array, auf das dst
Original: number of bytes 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. |
| ps | - | Zeiger auf die Umwandlung Zustand Objekt
Original: pointer to the conversion state object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
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. Wenn dst==NULL, gibt die Anzahl von Bytes, die geschrieben worden wäre .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. If dst==NULL, returns the number of bytes that would have been written.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), kehrt
static_cast<std::size_t>(-1), speichert EILSEQ in errno und verlässt *ps in unbestimmten Zustand .Original:
On conversion error (if invalid wide character was encountered), 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.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
#include <iostream>
#include <vector>
#include <clocale>
#include <string>
#include <cwchar>
void print_wide(const wchar_t* wstr)
{
std::mbstate_t state = std::mbstate_t();
int len = 1 + std::wcsrtombs(NULL, &wstr, 0, &state);
std::vector<char> mbstr(len);
std::wcsrtombs(&mbstr[0], &wstr, mbstr.size(), &state);
std::cout << "multibyte string: " << &mbstr[0] << '\n'
<< "Length, including '\\0': " << mbstr.size() << '\n';
}
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ß水𝄋"
print_wide(wstr);
}
Output:
multibyte string: zß水𝄋
Length, including '\0': 11
Siehe auch
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) | |
wandelt einen schmalen Multibyte Zeichenkette breite Zeichenfolge mit dem angegebenen Zustand 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. (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 wcsrtombs
| |