俄语网站建设注意事项,深圳电子厂,搭建网站步骤,网页界面设计图本地化库 本地环境设施包含字符分类和字符串校对、数值、货币及日期/时间格式化和分析#xff0c;以及消息取得的国际化支持。本地环境设置控制流 I/O 、正则表达式库和 C 标准库的其他组件的行为。 用本地环境的 ctype 刻面将字符转换为小写
std::tolower(std::locale) temp…本地化库 本地环境设施包含字符分类和字符串校对、数值、货币及日期/时间格式化和分析以及消息取得的国际化支持。本地环境设置控制流 I/O 、正则表达式库和 C 标准库的其他组件的行为。 用本地环境的 ctype 刻面将字符转换为小写
std::tolower(std::locale) template class charT charT tolower( charT ch, const locale loc );
用给定 loacale 的 std::ctype 平面所指定的转换规则若可能则转换字符 ch 为小写。
参数
ch-字符loc-本地环境
返回值
若 ch 的小写形式列于 locale 则返回它否则返回不更改的 ch 。
注意
此函数只能进行 1:1 字符映射例如希腊文大写字母 Σ 拥有二个小写形式取决于在词中的位置 σ 与 ς 。此情况下对 do_tolower 的调用不能获得正确的小写形式。
可能的实现
template class charT
charT tolower( charT ch, const std::locale loc ) {return std::use_facetstd::ctypecharT(loc).tolower(ch);
} 调用示例
#include iostream
#include localevoid try_with(wchar_t c, const char* locale)
{//用给定 loacale 的 std::ctype 平面所指定的转换规则若可能则转换字符 ch 为小写。std::cout tolower( c , locale(\ locale \)) returned std::boolalpha std::tolower(c, std::locale(locale)) std::endl;
}int main()
{//空格 (0x20, )//换页(0x0c, \f)//换行(0x0a, \n)//回车(0x0d, \r)//水平制表符(0x09, \t)//垂直制表符(0x0b, \v)std::cout std::boolalpha;std::locale locale1; // locale1 是经典 C 本地环境的副本std::cout locale1.name(): locale1.name() std::endl;std::locale locale2(Chinese (Simplified)_China.936); // locale2 为本地环境std::cout locale2.name(): locale2.name() std::endl;const wchar_t tolowerC L\u042f; // 西里尔大写字母 yatry_with(tolowerC, locale1.name().c_str());try_with(tolowerC, locale2.name().c_str());std::cout std::endl;const wchar_t tolowerC2 1; // ASCII 1try_with(tolowerC2, locale1.name().c_str());try_with(tolowerC2, locale2.name().c_str());std::cout std::endl;const wchar_t tolowerC3 1; // ASCII 1try_with(tolowerC3, locale1.name().c_str());try_with(tolowerC3, locale2.name().c_str());std::cout std::endl;const wchar_t tolowerC4 a; // ASCII atry_with(tolowerC4, locale1.name().c_str());try_with(tolowerC4, locale2.name().c_str());std::cout std::endl;const wchar_t tolowerC5 ,; // ASCII ,try_with(tolowerC5, locale1.name().c_str());try_with(tolowerC5, locale2.name().c_str());std::cout std::endl;const wchar_t tolowerC6 ; // ASCII try_with(tolowerC6, locale1.name().c_str());try_with(tolowerC6, locale2.name().c_str());std::cout std::endl;const wchar_t tolowerC7 A; //Atry_with(tolowerC7, locale1.name().c_str());try_with(tolowerC7, locale2.name().c_str());std::cout std::endl;return 0;
}输出
locale1.name(): C
locale2.name(): Chinese (Simplified)_China.936
tolower(1071, locale(C)) returned 1103
tolower(1071, locale(Chinese (Simplified)_China.936)) returned 1103tolower(49, locale(C)) returned 49
tolower(49, locale(Chinese (Simplified)_China.936)) returned 49tolower(1, locale(C)) returned 1
tolower(1, locale(Chinese (Simplified)_China.936)) returned 1tolower(97, locale(C)) returned 97
tolower(97, locale(Chinese (Simplified)_China.936)) returned 97tolower(44, locale(C)) returned 44
tolower(44, locale(Chinese (Simplified)_China.936)) returned 44tolower(32, locale(C)) returned 32
tolower(32, locale(Chinese (Simplified)_China.936)) returned 32tolower(65, locale(C)) returned 97
tolower(65, locale(Chinese (Simplified)_China.936)) returned 97