std:: isupper (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 isupper ( CharT ch, const locale & loc ) ; |
||
检查给定字符是否被指定区域的 std::ctype facet 归类为大写字母字符。
目录 |
参数
| ch | - | 字符 |
| loc | - | 区域设置 |
返回值
若字符被分类为大写字母则返回 true ,否则返回 false 。
可能的实现
template<class CharT> bool isupper(CharT ch, const std::locale& loc) { return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::upper, ch); } |
示例
演示了在不同区域设置(操作系统特定)下使用
std::isupper()
的方法。
运行此代码
#include <iostream> #include <locale> int main() { const wchar_t c = L'\u00de'; // LATIN CAPITAL LETTER THORN std::locale loc1("C"); std::cout << std::boolalpha << "isupper('Þ', C locale) returned " << std::isupper(c, loc1) << '\n' << "islower('Þ', C locale) returned " << std::islower(c, loc1) << '\n'; std::locale loc2("en_US.UTF8"); std::cout << "isupper('Þ', Unicode locale) returned " << std::isupper(c, loc2) << '\n' << "islower('Þ', Unicode locale) returned " << std::islower(c, loc2) << '\n'; }
可能的输出:
isupper('Þ', C locale) returned false
islower('Þ', C locale) returned false
isupper('Þ', Unicode locale) returned true
islower('Þ', Unicode locale) returned false
参阅
|
检查字符是否为大写字符
(函数) |
|
|
检查宽字符是否为大写字符
(函数) |