_ismbclegal

提供: RAD Studio
移動先: 案内検索

string.h:インデックス への移動


ヘッダーファイル

mbstring.h

カテゴリ

分類ルーチン

int _ismbclegal(unsigned int c);

説明

_ismbclegal は,c 引数の各バイトが現在使用中のコードページ内に存在するかどうかをテストします。

戻り値

現在のコードページで引数 c が有効なマルチバイト文字である場合,_ismbclegal は,0 以外の値を返します。そうでない場合は,0 を返します。


コード例

#include <mbstring.h>
bool checkValid(char* input)
{
  while (*input)
  {
    /* Of we have a MBCS char (lead + trail), check if it is valid in the current
       OS code-page by using _ismbclegal. This check should never fail since
       _ismbblead and _ismbbtrail are only sensitive for MBCS chars in the same CP.
     */
    if (_ismbblead(*input) && _ismbbtrail(*(input + 1)))
      if (!_ismbclegal(*input + (*(input + 1) << 8)))
        return false;

    input++;
  } 

  /* The check succeeded */
  return true;
}