std:: isspace (std::locale)
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<locale>
|
||
|
template
<
class
CharT
>
bool isspace ( CharT ch, const locale & loc ) ; |
||
指定された文字が、指定されたロケールの std::ctype ファセットによって空白文字として分類されるかどうかをチェックします。
目次 |
パラメータ
| ch | - | 文字 |
| loc | - | ロケール |
戻り値
文字が空白文字として分類される場合は 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
関連項目
|
文字が空白文字かどうかをチェックする
(関数) |
|
|
ワイド文字が空白文字かどうかをチェックする
(関数) |