std::mbrlen
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 mbrlen( const char* s, std::size_t n, std::mbstate_t* ps); |
||
Bestimmt die Gre in Bytes, der Rest des Multibyte-Zeichen, dessen erstes Byte wird durch
s hingewiesen, angesichts der aktuellen Konvertierungsstatus ps .Original:
Determines the size, in bytes, of the remainder of the multibyte character whose first byte is pointed to by
s, given the current conversion state ps.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.
Diese Funktion entspricht dem Aufruf
std::mbrtowc(nullptr, s, n, ps?ps:&internal) fr einige versteckte Objekt internal vom Typ std::mbstate_t, auer, dass der Ausdruck ps nur einmal ausgewertet wird .Original:
This function is equivalent to the call
std::mbrtowc(nullptr, s, n, ps?ps:&internal) for some hidden object internal of type std::mbstate_t, except that the expression ps is evaluated only once.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.
Parameter
| s | - | Zeiger auf ein Element einer Multibyte Zeichenkette
Original: pointer to an element of a multibyte character string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| n | - | Grenze fr die Anzahl von Bytes in s, die untersucht werden knnen
Original: limit on the number of bytes in s that can be examined 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 Variable, die die Umwandlung Zustand
Original: pointer to the variable holding the conversion state The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Rckgabewert
0 wenn die nchste n oder weniger Bytes die Null-Zeichen abgeschlossen .Original:
0 if the next n or fewer bytes complete the null character.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.
Die Anzahl der Bytes (zwischen
1 und n) ausfllen, dass ein gltiges Multibyte-ZeichenOriginal:
The number of bytes (between
1 and n) that complete a valid multibyte characterThe 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.
(size_t)-1 wenn die Kodierung Fehler auftrittOriginal:
(size_t)-1 if encoding error occursThe 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.
(size_t)-2 wenn die nchsten n bytes Teil eines mglicherweise gltiges Multibyte-Zeichen, die noch unvollstndig ist nach Prfung aller n Byte sindOriginal:
(size_t)-2 if the next n bytes are part of a possibly valid multibyte character, which is still incomplete after examining all n bytesThe 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 <clocale>
#include <string>
#include <iostream>
#include <cwchar>
int main()
{
// allow mbrlen() to work with UTF-8 multibyte encoding
std::setlocale(LC_ALL, "en_US.utf8");
// UTF-8 narrow multibyte encoding
std::string str = u8""; // or u8"\u6c34" or "\xe6\xb0\xb4"
std::mbstate_t mb = std::mbstate_t();
int len1 = std::mbrlen(&str[0], 1, &mb);
if(len1 == -2) {
std::cout << "The first 1 byte of " << str
<< " is an incomplete multibyte char (mbrlen returns -2)\n";
}
int len2 = std::mbrlen(&str[1], str.size()-1, &mb);
std::cout << "The remaining " << str.size()-1 << " bytes of " << str
<< " hold " << len2 << " bytes of the multibyte character\n";
std::cout << "Attempting to call mbrlen() in the middle of " << str
<< " while in initial shift state returns "
<< (int)mbrlen(&str[1], str.size(), &mb) << '\n';
}
Output:
The first 1 byte of is an incomplete multibyte char (mbrlen returns -2)
The remaining 2 bytes of hold 2 bytes of the multibyte character
Attempting to call mbrlen() in the middle of while in initial shift state returns -1
Siehe auch
wandelt die nchsten 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) | |
gibt die Anzahl der Bytes in den nchsten Multibyte-Zeichens Original: returns the number of bytes in the next multibyte character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktion) | |
[virtuell] |
berechnet die Lnge der Zeichenfolge, externT durch Umwandlung in gegebenen Internt Puffer verbraucht wrde Original: calculates the length of the externT string that would be consumed by conversion into given internT buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (virtuellen geschtzten Member-Funktion of std::codecvt)
|
C documentation for mbrlen
| |