Namespaces
Variants

std:: isblank (std::locale)

From cppreference.net
定义于头文件 <locale>
template < class CharT >
bool isblank ( CharT ch, const locale & loc ) ;
(C++11 起)

检查给定字符是否被指定区域的 std::ctype 刻面归类为空白字符。

目录

参数

ch - 字符
loc - 区域设置

返回值

若字符被分类为空白字符则返回 true ,否则返回 false

可能的实现

template<class CharT>
bool isblank(CharT ch, const std::locale& loc)
{
    return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::blank, ch);
}

示例

演示了在不同区域设置(操作系统特定)下使用 isblank() 的情况。

#include <iostream>
#include <locale>
void try_with(wchar_t c, const char* loc)
{
    std::wcout << "isblank('" << c << "', locale(\"" << loc << "\")) returned "
               << std::boolalpha
               << std::isblank(c, std::locale(loc)) << '\n';
}
int main()
{
    const wchar_t IDEO_SPACE = L'\u3000'; // Unicode character 'IDEOGRAPHIC SPACE'
    try_with(IDEO_SPACE, "C");
    try_with(IDEO_SPACE, "en_US.UTF-8");
}

可能的输出:

isblank(' ', locale("C")) returned false
isblank(' ', locale("en_US.UTF-8")) returned true

参见

(C++11)
检查字符是否为空白字符
(函数)
(C++11)
检查宽字符是否为空白字符
(函数)