std::mbsinit – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
| definiert in Header <cwchar> |
||
|
|
||
Wenn ps nicht ein NULL-Zeiger, bestimmt die mbsinit Funktion, ob die spitzen-to std::mbstate_t Objekt die anfängliche Wandlungspreis Zustand beschreibt .
Original:
If ps is not a null pointer, the mbsinit function determines whether the pointed-to std::mbstate_t object describes the initial conversion state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Notes
Obwohl eine Null initialisiert std::mbstate_t stellt immer die anfängliche Wandlungspreis Zustand, kann es andere Werte std::mbstate_t, die auch repräsentieren die anfängliche Wandlungspreis Zustand sein .
Original:
Although a zero-initialized std::mbstate_t always represents the initial conversion state, there may be other values of std::mbstate_t that also represent the initial conversion state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| ps | - | pointer to the std::mbstate_t object to examine |
Rückgabewert
0 wenn ps ist kein Null-Zeiger und nicht reporesent die anfängliche Wandlungspreis Zustand Wert ungleich Null sonst .
Original:
0 if ps is not a null pointer and does not reporesent the initial conversion state, nonzero value otherwise.
The text has been machine-translated via Google Translate.
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(); (void)std::mbrlen(&str[0], 1, &mb); if (!std::mbsinit(&mb)) { std::cout << "After processing the first 1 byte of " << str << " the conversion state is not initial\n"; } (void)std::mbrlen(&str[1], str.size()-1, &mb); if (std::mbsinit(&mb)) { std::cout << "After processing the remaining 2 bytes of " << str << ", the conversion state is initial conversion state\n"; } }
Output:
After processing the first 1 byte of 水 the conversion state is not initial After processing the remaining 2 bytes of 水, the conversion state is initial conversion state
Siehe auch
Konvertierungsstatus notwendigen Informationen, um Multibyte-Zeichenketten zu durchlaufen Original: conversion state information necessary to iterate multibyte character strings The text has been machine-translated via Google Translate. (Klasse) [edit] | |