名稱空間
變體
操作

std::isblank(std::locale)

來自 cppreference.com
< cpp‎ | 本地化
 
 
 
 
定義於標頭檔案 <locale>
template< class CharT >
bool isblank( CharT ch, const locale& loc );
(C++11 起)

檢查給定字元是否被給定本地化設定的 std::ctype facet 分類為空白字元。

目錄

[編輯] 引數

ch - 字元
loc - locale

[編輯] 返回值

如果字元被分類為空白字元,則返回 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)
檢查寬字元是否為空白字元
(函式) [編輯]