std:: ispunct (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 in Header
<locale>
|
||
|
template
<
class
CharT
>
bool ispunct ( CharT ch, const locale & loc ) ; |
||
Prüft, ob das gegebene Zeichen durch die std::ctype Facette des gegebenen Gebietsschemas als Interpunktionszeichen klassifiziert wird.
Inhaltsverzeichnis |
Parameter
| ch | - | Zeichen |
| loc | - | Gebietsschema |
Rückgabewert
Gibt true zurück, wenn das Zeichen als Interpunktion klassifiziert wird, false andernfalls.
Mögliche Implementierung
template<class CharT> bool ispunct(CharT ch, const std::locale& loc) { return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::punct, ch); } |
Beispiel
Demonstriert die Verwendung von
std::ispunct()
mit verschiedenen Locales (betriebssystemspezifisch).
Diesen Code ausführen
#include <iostream> #include <locale> int main() { const wchar_t c = L'\u214b'; // upside-down ampersand std::locale loc1("C"); std::cout << "ispunct('⅋', C locale) returned " << std::boolalpha << std::ispunct(c, loc1) << '\n'; std::locale loc2("en_US.UTF-8"); std::cout << "ispunct('⅋', Unicode locale) returned " << std::boolalpha << std::ispunct(c, loc2) << '\n'; }
Mögliche Ausgabe:
isalpha('⅋', C locale) returned false
isalpha('⅋', Unicode locale) returned true
Siehe auch
|
prüft, ob ein Zeichen ein Satzzeichen ist
(Funktion) |
|
|
prüft, ob ein Breitzeichen ein Satzzeichen ist
(Funktion) |