Namensräume
Varianten
Aktionen

std::mbsrtowcs

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
mbtowc
mbstowcs
btowc
mbrtowc
mbsrtowcs
mbrtoc16(C++11)
mbrtoc32(C++11)
mblen
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 mbsrtowcs( wchar_t* dst,

                       const char** src,
                       std::size_t len,

                       std::mbstate_t* ps );
Konvertiert eine null-terminierte Multibyte-Zeichen-Sequenz, die bei der Umwandlung Zustand *ps beschrieben, aus dem Array, dessen erstes Element wird durch *src seiner breiten Zeichendarstellung wies beginnt. Wenn dst nicht null ist, umgewandelt werden Zeichen in den aufeinanderfolgenden Elementen des wchar_t Array, auf das dst gespeichert. Nicht mehr als len breite Zeichen werden dem Ziel-Array geschrieben .
Original:
Converts a null-terminated multibyte character sequence, which begins in the conversion state described by *ps, from the array whose first element is pointed to by *src to its wide character representation. If dst is not null, converted characters are stored in the successive elements of the wchar_t array pointed to by dst. No more than len wide characters 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.
Jede Multibyte-Zeichen ist, als ob durch einen Aufruf std::mbrtowc umgewandelt. Die Umwandlung gestoppt, wenn:
Original:
Each multibyte character is converted as if by a call to std::mbrtowc. 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.
  • Der Multibyte Nullzeichen wurde umgewandelt und gespeichert. src eingestellt ist NULL und *ps stellt den ersten Schaltzustand .
    Original:
    The multibyte null character was converted and stored. src is set to NULL and *ps represents 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.
  • Ein ungültiges Multibyte-Zeichen (nach der aktuellen C locale) angetroffen wurde. src wird zu Beginn der ersten umgesetzten Multibyte-Zeichen zeigen .
    Original:
    An invalid multibyte character (according to the current C locale) was encountered. src is set to point at the beginning of the first unconverted multibyte 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 große Zeichen gespeichert werden übersteigen würde len. src wird zu Beginn der ersten umgesetzten Multibyte-Zeichen zeigen. Dieser Zustand wird nicht geprüft, ob dst==NULL .
    Original:
    the next wide character to be stored would exceed len. src is set to point at the beginning of the first unconverted multibyte character. This condition is not checked if dst==NULL.
    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

dst -
Zeiger auf breite Zeichen-Array, wo die Ergebnisse gespeichert werden
Original:
pointer to wide character array where the results 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 Multibyte-String
Original:
pointer to pointer to the first element of a null-terminated multibyte 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 weiten Zeichen im Array, auf das dst
Original:
number of wide characters 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.

[Bearbeiten] Rückgabewert

Bei Erfolg gibt die Anzahl der weiten Zeichen, mit Ausnahme des abschließenden L'\0', geschrieben, um die Zeichen-Array .. Wenn dst==NULL, gibt die Anzahl der weiten Zeichen, die gegeben unbegrenzter Länge geschrieben worden wäre .
Original:
On success, returns the number of wide characters, excluding the terminating L'\0', written to the character array.. If dst==NULL, returns the number of wide characters that would have been written given unlimited length.
The text has been machine-translated via Google Translate.
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 multibyte 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.

[Bearbeiten] Beispiel

#include <iostream>
#include <vector>
#include <clocale>
#include <cwchar>
 
void print_as_wide(const char* mbstr)
{
    std::mbstate_t state = std::mbstate_t();
    int len = 1 + std::mbsrtowcs(NULL, &mbstr, 0, &state);
    std::vector<wchar_t> wstr(len);
    std::mbsrtowcs(&wstr[0], &mbstr, wstr.size(), &state);
    std::wcout << "Wide string: " << &wstr[0] << '\n'
               << "The length, including '\\0': " << wstr.size() << '\n';
}
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    const char* mbstr = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
                        // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
    print_as_wide(mbstr);
}

Output:

Wide string: zß水𝄋
The length, including '\0': 5

[Bearbeiten] Siehe auch

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]
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) [edit]
[virtuell]
wandelt eine Zeichenkette aus externT um Internt wie beim Lesen aus Datei
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.

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