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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Défini dans l'en-tête
<locale>
|
||
|
template
<
class
CharT
>
bool ispunct ( CharT ch, const locale & loc ) ; |
||
Vérifie si le caractère donné est classé comme un caractère de ponctuation par la facette std::ctype de la locale spécifiée.
Table des matières |
Paramètres
| ch | - | caractère |
| loc | - | paramètres régionaux |
Valeur de retour
Retourne true si le caractère est classifié comme ponctuation, false sinon.
Implémentation possible
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); } |
Exemple
Illustre l'utilisation de
std::ispunct()
avec différentes locales (spécifiques au système d'exploitation).
Exécuter ce code
#include <iostream> #include <locale> int main() { const wchar_t c = L'\u214b'; // esperluette inversée 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'; }
Sortie possible :
isalpha('⅋', C locale) returned false
isalpha('⅋', Unicode locale) returned true
Voir aussi
|
vérifie si un caractère est un caractère de ponctuation
(fonction) |
|
|
vérifie si un caractère large est un caractère de ponctuation
(fonction) |