C++ 参考手册
- C++11
- C++14
- C++17
- C++20
- C++ 编译器支持情况表
- 独立与宿主实现
- C++ 语言
- C++ 关键词
- 预处理器
- C++ 标准库头文件
- 具名要求
- 功能特性测试 (C++20)
- 工具库
- 类型支持(基本类型、RTTI、类型特性)
- 概念库 (C++20)
- 错误处理
- 动态内存管理
- 日期和时间工具
- 字符串库
- std::basic_string
- std::basic_string_view
- 空终止字节字符串
- 空终止多字节字符串
- 空终止宽字符串
- std::towlower
- std::wctype
- std::iswctype
- std::iswcntrl
- std::iswprint
- std::iswspace
- std::iswblank
- std::iswgraph
- std::iswpunct
- std::iswalnum
- std::iswalpha
- std::iswupper
- std::iswlower
- std::iswdigit
- std::iswxdigit
- std::towupper
- std::wctrans
- std::towctrans
- std::wcstol, std::wcstoll
- std::wcstoul, std::wcstoull
- std::wcstof, std::wcstod, std::wcstold
- std::wcstoimax, std::wcstoumax
- std::wcslen
- std::wcscpy
- std::wcsncpy
- std::wcscat
- std::wcsncat
- std::wcscmp
- std::wcscoll
- std::wcsncmp
- std::wcsxfrm
- std::wcschr
- std::wcsrchr
- std::wcspbrk
- std::wcsspn
- std::wcscspn
- std::wcsstr
- std::wcstok
- std::wmemcpy
- std::wmemmove
- std::wmemcmp
- std::wmemchr
- std::wmemset
- std::char_traits
- 注释
- 容器库
- 迭代器库
- 范围库 (C++20)
- 算法库
- 数值库
- 输入/输出库
- 文件系统库
- 本地化库
- 正则表达式库
- 原子操作库
- 线程支持库
- 实验性 C++ 特性
- 有用的资源
- 索引
- std 符号索引
- 协程支持 (C++20)
- C++ 关键词
std::iswspace
检查给定宽字符是否为当前安装的 C 本地环境分类为宽空白字符。在默认本地环境中,下列字符是空白符:
- 空格(
0x20、 ' ' ) - 换页符(
0x0c、 '\f' ) - 换行符(
0x0a、 '\n' ) - 回车(
0x0d、 '\r' ) - 水平制表符(
0x09、 '\t' ) - 垂直制表符(
0x0b、 '\v' )
若 ch 的值既不能表示为 wchar_t 又不等于宏 WEOF ,则行为未定义。
参数
| ch | - | 宽字符 |
返回值
若宽字符为空白符则为非零值,否则为零。
注意
ISO 30112 定义 POSIX 空白符为 Unicode 字符 U+0009..U+000D 、 U+0020 、 U+1680 、 U+180E 、 U+2000..U+2006 、 U+2008..U+200A 、 U+2028 、 U+2029 、 U+205F 及 U+3000 。
示例
演示以不同本地环境使用 iswspace()
运行此代码
#include <iostream> #include <clocale> #include <cwctype> void try_with(wchar_t c, const char* loc) { std::setlocale(LC_ALL, loc); std::wcout << "isspace('" << c << "') in " << loc << " locale returned " << std::boolalpha << (bool)std::iswspace(c) << '\n'; } int main() { wchar_t EM_SPACE = L'\u2003'; // Unicode 字符 'EM SPACE' try_with(EM_SPACE, "C"); try_with(EM_SPACE, "en_US.UTF8"); }
输出:
isspace(' ') in C locale returned false
isspace(' ') in en_US.UTF8 locale returned true
参阅
| 检查字符是否被本地环境分类为空白 (函数模板) | |
| 检查字符是否为空白间隔字符 (函数) |
| ASCII 值 | 字符 |
isspace |
|||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 十进制 | 十六进制 | 八进制 | |||||||||||||
| 0–8 | \x0–\x8
|
\0–\10
|
控制码 (NUL 等)
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 9 | \x9
|
\11
|
制表 (\t)
|
≠0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 10–13 | \xA–\xD
|
\12–\15
|
空白符 (\n, \v, \f, \r)
|
≠0
|
0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 14–31 | \xE–\x1F
|
\16–\37
|
控制码 | ≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 32 | \x20
|
\40
|
space | 0
|
≠0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 33–47 | \x21–\x2F
|
\41–\57
|
!"#$%&'()*+,-./
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 48–57 | \x30–\x39
|
\60–\71
|
0123456789
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
0
|
0
|
0
|
≠0
|
≠0
|
| 58–64 | \x3A–\x40
|
\72–\100
|
:;<=>?@
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 65–70 | \x41–\x46
|
\101–\106
|
ABCDEF
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
≠0
|
0
|
0
|
≠0
|
| 71–90 | \x47–\x5A
|
\107–\132
|
GHIJKLMNOPQRSTUVWXYZ
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
≠0
|
0
|
0
|
0
|
| 91–96 | \x5B–\x60
|
\133–\140
|
[\]^_`
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 97–102 | \x61–\x66
|
\141–\146
|
abcdef
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
0
|
≠0
|
0
|
≠0
|
| 103–122 | \x67–\x7A
|
\147–\172
|
ghijklmnopqrstuvwxyz
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
0
|
≠0
|
0
|
0
|
| 123–126 | \x7B–\x7E
|
\172–\176
|
{|}~
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 127 | \x7F
|
\177
|
退格字符 (DEL)
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|