_ismbblead, _ismbbtrail
Nach oben zu string.h - Index
Header-Datei
mbstring.h
Kategorie
Klassifizierungsroutinen
Prototyp
int _ismbblead(unsigned int c);
int _ismbbtrail(unsigned int c);
Beschreibung
Mit _ismbblead und _ismbbtrail kann geprüft werden, ob das Argument c das erste oder das zweite Byte eines Multibyte-Zeichens ist.
_ismbblead und _ismbbtrail werden von der verwendeten Codeseite beeinflusst. Sie können die Codeseite mithilfe der Funktion _setlocale festlegen.
Rückgabewert
Ist c das führende Byte eines Multibyte-Zeichens, gibt _ismbblead true zurück.
Ist c das nachstehende Byte eines Multibyte-Zeichens, gibt _ismbbtrail einen Wert ungleich Null zurück.
Beispiel
#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; }