isblank() — Test for blank character classification

Standards

Standards / Extensions C or C++ Dependencies

Language Environment
Single UNIX Specification, Version 3
C++ TR1 C99

both  

Format

#include <ctype.h>

int isblank(int c);

General description

Tests whether the current LC_CTYPE locale category assigns c the blank character attribute. The tab and space characters have the blank attribute in the POSIX locale (with name “POSIX” or “C”).

To avoid infringing on the user's name space, this nonstandard function has two names. One name is prefixed with two underscore characters, and one name is not. The name without the prefix underscore characters is exposed only when you use LANGLVL(EXTENDED).

To use this function, you must either invoke the function using its external entry point name (for example, the name that begins with two underscore characters), or compile with LANGLVL(EXTENDED). When you use LANGLVL(EXTENDED) any relevant information in the header is also exposed.

Note: The isblank() function has a dependency on the level of the Enhanced ASCII Extensions. See Enhanced ASCII support for details.

Returned value

isblank() returns nonzero if the current LC_CTYPE locale category assigns c the blank character attribute.

Otherwise, isblank() returns 0.

Example

/* This example tests if c is a blank type.  */
#include <stdio.h>
#include <ctype.h>
#include <locale.h>

void check(char c) {
  if ((c != ' ') && (isprint(c)))
    printf(" %c  is ", c);
  else
    printf("x%02x is ", c);
  if (!isblank(c))
    printf("not ");
  puts("a blank type character");
}

main() {
  printf("\nIn LC_CTYPE category of locale \ with name \"%s\":\n",
     setlocale(LC_CTYPE, NULL));
  check('a');
  check(' ');
  check(0x00);
  check('\n');
  check('\t');
}
Output:
In LC_CTYPE category of locale with name “……”;
 a  is not a blank type character
x40 is a blank type character
x00 is not a blank type character
x15 is not a blank type character
x05 is a blank type character

Related information