_ismbblead, _ismbbtrail
string.h:インデックス への移動
ヘッダーファイル
mbstring.h
カテゴリ
分類ルーチン
プロトタイプ
int _ismbblead(unsigned int c);
int _ismbbtrail(unsigned int c);
説明
_ismbblead および _ismbbtrail を使用して,引数 c がマルチバイト文字の先行バイトか後続バイトかをテストします。
_ismbblead および _ismbbtrail は,使用中のコードページに依存します。コードページを設定するには,_setlocale 関数を使用します。
戻り値
c がマルチバイト文字の先行バイトである場合,_ismbblead は 0 以外の値を返します。
c がマルチバイト文字の後続バイトである場合,_ismbbtrail は 0 以外の値を返します。
コード例
#include <mbstring.h>
bool checkMBCSString(char* input)
{
/* Check if the given MBCS sequence is correct */
bool wasLead = false;
while (*input)
{
if (_ismbblead(*input))
wasLead = true;
else if (_ismbbtrail(*input))
{
/* Check that a trail char should follow the lead one */
if (!wasLead)
return false;
else
wasLead = false;
}
input++;
}
/* The check succeeded if the last byte in the sequence was not a lead one */
return !wasLead;
}