C Standard Library

C <wctype.h> - iswxdigit() Function



The C <wctype.h> iswxdigit() function is used to check if the given wide character is a hexadecimal digit or not. Hexadecimal digits are one of the following character: 0123456789abcdefABCDEF.

Syntax

int iswxdigit ( wint_t ch );  

Parameters

ch Specify the wide character to be checked, casted to an wint_t, or WEOF.

Return Value

Returns non-zero value (i.e, true) if ch is a hexadecimal digit, else returns zero (i.e, false).

Example:

The example below shows the usage of iswxdigit() function.

#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
 
int main (){
  wchar_t str[] = L"ff123YZ";

  //counting the numbers of wide 
  //hexadecimal digits in str
  int i = 0, count = 0;
  while(str[i]) {
    if(iswxdigit(str[i]))
      count++;
    i++;
  }

  //displaying the output
  printf("%ls contains %d hexadecimal digits.", str, count);  
  return 0;
}

The output of the above code will be:

ff123YZ contains 5 hexadecimal digits.

❮ C <wctype.h> Library