_ismbclegal
Remonter à string.h - Index
Header File
mbstring.h
Category
Classification Routines
Prototype
int _ismbclegal(unsigned int c);
Description
_ismbclegal tests whether each byte of the c argument is in the code page that is currently in use.
Return Value
_ismbclegal returns a nonzero value if the argument c is a valid multibyte character on the current code page. Otherwise, the function returns zero.
Example
#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;
}