_ismbclegal

Aus RAD Studio
Wechseln zu: Navigation, Suche

Nach oben zu string.h - Index


Header-Datei

mbstring.h

Kategorie

Klassifizierungsroutinen

Prototyp

int _ismbclegal(unsigned int c);

Beschreibung

_ismbclegal prüft, ob jedes Byte des Arguments c in der aktuell verwendeten Codeseite enthalten ist.

Rückgabewert

_ismbclegal gibt einen Wert ungleich Null zurück, wenn das Argument c ein in der aktuell verwendeten Codeseite gültiges Multibyte-Zeichen ist. Andernfalls gibt die Funktion Null zurück.

Beispiel

#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;
}