C Standard Library

C <wctype.h> - iswspace() Function



The C <wctype.h> iswspace() function is used to check if the given wide character is a wide whitespace character. In the default "C" locale, the wide whitespace characters are the following:

  • Space (L' ', 0x20)
  • Feed (L'\f', 0x0c)
  • Newline (L'\n', 0x0a)
  • Carriage return (L'\r', 0x0d)
  • Horizontal tab (L'\t', 0x09)
  • Vertical tab (L'\v', 0x0b)

Other locales may consider a different selection of wide characters as wide whitespace characters.

Syntax

int iswspace ( 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 wide whitespace character, else returns zero (i.e, false).

Example:

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

#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
 
int main (){
  wchar_t str[50] = L"To\rbe,\nor not to\tbe";

  //replacing the wide whitespace character
  //with wide new line character in str
  int i = 0;
  while(str[i]) {
    if(iswspace(str[i]))
      str[i] = L'\n';
    i++;
  }

  //displaying the output
  printf("str contains:\n%ls", str);  
  return 0;
}

The output of the above code will be:

str contains:
To
be,
or
not
to
be

❮ C <wctype.h> Library