名前空間
変種
操作

std::mbsinit

提供: cppreference.com
< cpp‎ | string‎ | multibyte

 
 
ストリングスライブラリ
NULLで終わる文字列
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.
バイト文字列
文字列をマルチバイト
ワイド文字列
クラス
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
 
NULLで終わるマルチバイト文字列
マルチバイト/ワイドコンバージョン
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
タイプ
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>
int mbsinit( const std::mbstate_t* ps);
psがNULLポインタでない場合、mbsinit機能は先の尖ったトゥstd::mbstate_tオブジェクトが初期変換状態を記述しているかどうかを決定し.
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.

目次

[編集] ノート

ゼロ初期化std::mbstate_t常に初期変換状態を表しますが、また、初期変換状態を表すstd::mbstate_tの他の値があるかもしれません.
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.

[編集] パラメータ

ps - pointer to the std::mbstate_t object to examine

[編集] 値を返します

0場合psNULLポインタでないと、そうでない場合は初期変換状態、ゼロ以外の値をreporesentはありません.
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.

[編集]

#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

[編集] も参照してください

マルチバイト文字列を反復処理するために必要な変換状態情報
Original:
conversion state information necessary to iterate multibyte character strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラス) [edit]
C documentation for mbsinit