std::islower(std::locale)
来自cppreference.com
<tbody>
</tbody>
| 在标头 <locale> 定义
|
||
template< class CharT > bool islower( CharT ch, const locale& loc ); |
||
检查给定字符按给定本地环境的 std::ctype 刻面是否分类为小写字母字符。
参数
| ch | - | 字符 |
| loc | - | 本地环境 |
返回值
若给定字符被分类为小写则返回 true,否则返回 false。
可能的实现
template<class CharT>
bool islower(CharT ch, const std::locale& loc)
{
return std::use_facet<std::ctype<CharT>>(loc).is(std::ctype_base::lower, ch);
}
|
示例
演示用不同本地环境使用 islower()(OS 特定)。
运行此代码
#include <iostream>
#include <locale>
int main()
{
const wchar_t c = L'\u03c0'; // 希腊文小写字母 pi
std::locale loc1("C");
std::cout << std::boolalpha
<< "islower('π', C 本地环境) 返回 "
<< std::islower(c, loc1) << '\n'
<< "isupper('π', C 本地环境) 返回 "
<< std::isupper(c, loc1) << '\n';
std::locale loc2("en_US.UTF8");
std::cout << "islower('π', Unicode 本地环境) 返回 "
<< std::islower(c, loc2) << '\n'
<< "isupper('π', Unicode 本地环境) 返回 "
<< std::isupper(c, loc2) << '\n';
}
可能的输出:
islower('π', C 本地环境) 返回 false
isupper('π', C 本地环境) 返回 false
islower('π', Unicode 本地环境) 返回 true
isupper('π', Unicode 本地环境) 返回 false
参阅
| 检查字符是否为小写 (函数) | |
| 检查宽字符是否为小写 (函数) |