std::ctype_byname<char>
来自 cppreference.com
定义在头文件 <locale> 中 |
||
template<> class ctype_byname : public std::ctype<char>; |
||
此 std::ctype_byname 的特化封装了类型 char 的字符分类功能。与其基类 std::ctype<char>
相似,与通用 std::ctype_byname 不同的是,使用表查找来对字符进行分类
内容 |
[编辑] 成员类型
成员类型 | 定义 |
mask
|
ctype<char>::mask
|
[编辑] 成员函数
(构造函数) |
构造一个新的 ctype_byname<char> 面 (公有成员函数) |
(析构函数) |
析构一个 ctype_byname<char> 面 (受保护的成员函数) |
从 std::ctype<char> 继承而来
成员类型
成员类型 | 定义 |
char_type
|
char
|
成员对象
成员名称 | 类型 |
id (static) |
std::locale::id |
table_size (static const) |
std::size_t 分类表的大小,至少为 256 |
成员函数
获取字符分类表 (public member function of std::ctype<char> ) | |
[static] |
获取 "C" 区域设置字符分类表 (public static member function of std::ctype<char> ) |
使用分类表对字符或字符序列进行分类 (public member function of std::ctype<char> ) | |
使用分类表定位序列中第一个符合给定分类的字符 (public member function of std::ctype<char> ) | |
使用分类表定位序列中第一个不符合给定分类的字符 (public member function of std::ctype<char> ) | |
调用 do_toupper (public member function of std::ctype<CharT> ) | |
调用 do_tolower (public member function of std::ctype<CharT> ) | |
调用 do_widen (public member function of std::ctype<CharT> ) | |
调用 do_narrow (public member function of std::ctype<CharT> ) |
受保护的成员函数
[virtual] |
将字符或字符序列转换为大写 (virtual protected member function of std::ctype<CharT> ) |
[virtual] |
将字符或字符序列转换为小写 (virtual protected member function of std::ctype<CharT> ) |
[virtual] |
将字符或字符序列从 char 转换为 CharT (virtual protected member function of std::ctype<CharT> ) |
[virtual] |
将字符或字符序列从 CharT 转换为 char(virtual protected member function of std::ctype<CharT> ) |
从 std::ctype_base 继承而来
成员类型
类型 | 定义 |
mask
|
未指定的位掩码类型(枚举、整数类型或位集) |
成员常量
space [static] |
mask 的值,标识空格字符分类(公有静态成员常量) |
print [static] |
mask 的值,标识可打印字符分类(公有静态成员常量) |
cntrl [static] |
mask 的值,标识控制字符分类(公有静态成员常量) |
upper [static] |
mask 的值,标识大写字符分类(公有静态成员常量) |
lower [static] |
mask 的值,标识小写字符分类(公有静态成员常量) |
alpha [static] |
mask 的值,标识字母字符分类(公有静态成员常量) |
digit [static] |
mask 的值,标识数字字符分类(公有静态成员常量) |
punct [static] |
mask 的值,标识标点字符分类(公有静态成员常量) |
xdigit [static] |
mask 的值,标识十六进制数字字符分类(公有静态成员常量) |
blank [static] (C++11) |
mask 的值,标识空白字符分类(公有静态成员常量) |
alnum [static] |
alpha | digit (公有静态成员常量) |
graph [static] |
alnum | punct (公有静态成员常量) |
[编辑] 示例
运行此代码
#include <iostream> #include <locale> int main() { char c = '\xde'; // capital letter thorn std::locale loc("C"); std::cout << "isupper('Þ', C locale) returned " << std::boolalpha << std::isupper(c, loc) << '\n'; loc = std::locale(loc, new std::ctype_byname<char>("en_US.utf8")); std::cout << "isupper('Þ', C locale with Unicode ctype<char>) returned " << std::boolalpha << std::isupper(c, loc) << '\n'; loc = std::locale(loc, new std::ctype_byname<char>("is_IS.iso88591")); std::cout << "isupper('Þ', C locale with Islandic ctype<char>) returned " << std::boolalpha << std::isupper(c, loc) << '\n'; }
输出
isupper('Þ', C locale) returned false isupper('Þ', C locale with Unicode ctype<char>) returned false isupper('Þ', C locale with Islandic ctype<char>) returned true
[编辑] 参见
定义字符分类表 (类模板) | |
std::ctype 的char 类型特化 (类模板特化) |