_ismbslead, _ismbstrail

De Appmethod Topics
Aller à : navigation, rechercher

Remonter à string.h - Index


Header File

mbstring.h

Category

Classification Routines

Prototype

int _ismbslead(const unsigned char *s1, const unsigned char *s2);

int _ismbstrail(const unsigned char *s1, const unsigned char *s2);

Description

The _ismbslead and _ismbstrail functions test the s1 argument to determine whether the s2 argument is a pointer to the lead byte or the trail byte. The test is case-sensitive.

Return Value

The _ismbslead and _ismbstrail routines return -1 if s2 points to a lead byte or a trail byte, respectively. If the test is false, the routines return zero.

Example

#include <mbstring.h>
bool checkMBCSString(char* input)
{
  char* ptr = input;

  /* Check if the given MBCS sequence is correct */
  while (*ptr)
  {
    if (_ismbslead(input, ptr))
    {
      /* The check succeeds for correct MBCS sequences */
      if (!_ismbstrail(input, ptr + 1))
        return false;
    }

    ptr++;
  }

  /* The check succeeded */
  return true;
}