_ismbblead, _ismbbtrail
Go Up to string.h Index
Header File
mbstring.h
Category
Classification Routines
Prototype
int _ismbblead(unsigned int c);
int _ismbbtrail(unsigned int c);
Description
_ismbblead and _ismbbtrail are used to test whether the argument c is the first or the second byte of a multibyte character.
_ismbblead and _ismbbtrail are affected by the code page in use. You can set the code page by using the _setlocale function.
Return Value
If c is in the lead byte of a multibyte character, _ismbblead returns true.
If c is in the trail byte of a multibyte character, _ismbbtrail returns a nonzero value.
Example
#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; }