函式
<cwctype>

iswspace

int iswspace (wint_t c);
檢查寬字元是否為空白字元
檢查 c 是否是空白字元

空白字元是指在特定區域設定中被視為空格,用於分隔單詞、行和/或段落的字元。

此函式是 isspace (<cctype>) 的寬字元版本:如果 c 透過 wctob 轉換為一個字元,並且該字元對於 isspace 為真,則此函式也始終認為它是一個空白字元

在 C++ 中,此函式的一個針對特定區域設定的模板版本 (isspace) 存在於標頭檔案 <locale> 中,適用於所有字元型別。

引數

c
要檢查的寬字元,強制轉換為wint_t型別,或WEOF.
wint_t 是一個整數型別。

返回值

如果 c 確實是空白字元,則返回一個非零值(即true),如果 c 確實是一個空白字元。否則返回零(即false)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* iswspace example */
#include <stdio.h>
#include <wctype.h>
int main ()
{
  wchar_t c;
  int i=0;
  wchar_t str[] = L"Example sentence to test iswspace\n";
  while (str[i])
  {
    c=str[i];
    if (iswspace(c)) c = L'\n';
    putwchar (c);
    i++;
  }
  return 0;
}

輸出
Example
sentence
to 
test
iswspace


另見