std::isspace(std::locale)
From cppreference.com
| ヘッダー <locale> で定義 |
||
| template< class CharT > bool isspace( CharT ch, const locale& loc ); |
||
指定されたロケールの std::ctype ファセットによって空白文字として分類されるかどうかを指定された文字をチェックします。
目次 |
[編集] パラメータ
| 文字 | - | 文字 |
| loc | - | locale |
[編集] 戻り値
文字が空白文字として分類される場合は true を返し、そうでない場合は false を返します。
[編集] 実装例
template<class CharT> bool isspace(CharT ch, const std::locale& loc) { return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::space, ch); } |
[編集] 例
さまざまなロケール (OS 固有) で std::isspace() を使用する方法を示します。
このコードを実行
#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 character '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[編集] 関連項目
| 文字が空白文字か調べる (関数) | |
| ワイド文字が空白文字であるかチェックする (関数) |