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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definiert im Header
<locale>
|
||
|
template
<
class
CharT
>
bool isspace ( CharT ch, const locale & loc ) ; |
||
Überprüft, ob das gegebene Zeichen durch die std::ctype Facette der gegebenen Locale als Leerzeichen klassifiziert wird.
Inhaltsverzeichnis |
Parameter
| ch | - | Zeichen |
| loc | - | Gebietsschema |
Rückgabewert
Gibt true zurück, wenn das Zeichen als Leerzeichen klassifiziert ist, false andernfalls.
Mögliche Implementierung
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); } |
Beispiel
Demonstriert die Verwendung von
std::isspace()
mit verschiedenen Locales (betriebssystemspezifisch).
Diesen Code ausführen
#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"); }
Mögliche Ausgabe:
isspace(' ', locale("C")) returned false
isspace(' ', locale("en_US.UTF8")) returned true
Siehe auch
|
prüft, ob ein Zeichen ein Leerzeichen ist
(Funktion) |
|
|
prüft, ob ein Breitzeichen ein Leerzeichen ist
(Funktion) |