std::isspace(std::locale)_C++中文网
| template< class charT > |
||
检查给定字符是否为给定 locale 的 ctype 平面分类为空白字符。
参数
返回值
若字符被分类为空白字符则返回 true ,否则返回 false 。
可能的实现
示例
演示以不同本地环境使用 isspace() ( OS 限定)。
#include <iostream> #include <locale> void try_with(wchar_t c, const char* loc) { std::wcout << "isspace('" << c << "', locale(\"" << loc << "\")) returned " << std::boolalpha << std::isspace(c, std::locale(loc)) << '\n'; } int main() { const wchar_t EM_SPACE = L'\u2003'; // Unicode 字符 'EM SPACE' try_with(EM_SPACE, "C"); try_with(EM_SPACE, "en_US.UTF8"); }
输出:
isspace(' ', locale("C")) returned false
isspace(' ', locale("en_US.UTF8")) returned true