扬州网站开发,详情页设计收费,射阳县住房和城乡建设局网站,如何创建网站的详细步骤wint_t towlower ( wint_t wc );towlower() 函数用来将大写字母转换为小写字母(针对宽字符)。只有当参数 wc 是一个大写字母#xff0c;并且存在对应的小写字母时#xff0c;这种转换才会发生。towlower() 是 tolower() 的宽字符版本。参数wc要被转换的宽字符。它可以是一个有…wint_t towlower ( wint_t wc );towlower() 函数用来将大写字母转换为小写字母(针对宽字符)。只有当参数 wc 是一个大写字母并且存在对应的小写字母时这种转换才会发生。towlower() 是 tolower() 的宽字符版本。参数wc要被转换的宽字符。它可以是一个有效的宽字符(被转换为 wint_t 类型)也可以是 WEOF(表示无效的宽字符)。返回值如果转换成功那么返回与 wc 对应的小写字母如果转换失败那么直接返回 wc(值未变)。注意返回值为 wint_t 类型你可能需要隐式或者显式地将它转换为 wchar_t 类型。实例将一个宽字符串中的大写字母转换为小写字母。#include #include #include int main (){int i0;wchar_t str[] LC C Java Python GoLang\n;wchar_t c;while (str[i]){c str[i];putwchar (towlower(c));i;}return 0;}运行结果c c java python golang关于大写字母和小写字母人们通常认为只有acb...xyz才是小写字母只有ABC...XYZ才是大写字母其实这是不对的。大小写字母并不是固定的不同的语言文化可能会包含不同的大小写字母例如在“简体中文”环境中西里尔文БГЁ、希腊文ΣΩΔΨΦ(数学物理公式中常用希腊字母)等都将成为大写字母它们对应的小写字母是бгё - σωδψφ。我们可以通过 setlocale() 函数改变程序的地域设置让程序使用不同的字符集从而支持不同的语言文化。在默认的地域设置(默认为C)中C语言通常使用 ASCII 编码能较好地支持英文此时的大写字母包括A B C D E F G H I J K L M N O P Q R S T U V W X Y Z小写字母包括a b c d e f g h i j k l m n o p q r s t u v w x y z在其它地域设置中可能会使用 GBK(简体中文)、BIG5(繁体中文)、Shift-JIS(日文)、Unicode(世界统一码) 等更加复杂的编码它们包含了更多的大小写字母。也就是说一个宽字符是否是大写字母或者小写字母和程序的地域设置有关不同的地域设置会包含不同的大小写字母。字母一定要区分大小写吗我们通常认为一个字母要么是小写字母要么是大写字母并且一个小写字母必定对应一个大写字母反之亦然。这种说法虽然适用于默认的地域设置(默认为C)但是并不一定适用于其它的地域设置。以 Windows 下的“简体中文”环境为例拼音āōūǖ都将成为小写字母但是它们没有对应的大写字母。Windows 下的“简体中文”环境使用 GBK 编码该编码并没有包含ĀŌŪǕ这些大写形式。罗马数字ⅲⅵⅶⅸ和ⅢⅥⅦⅨ也会被视为字母并且从视觉上看起来是大小写对应的。其实不然对于 Windows 来说ⅲⅵⅶⅸ和ⅢⅥⅦⅨ都仅仅是字母而已并没有所谓的“大小写”形式换句话说它们既不是大写字母也不是小写字母仅仅是字母而已。以上说法仅适用于 Windows在 Linux 和 Mac OS 下使用“简体中文”情况会有所不同āōūǖ会有对应的大写字母ĀŌŪǕ因为 Linux 和 Mac OS 下的“简体中文”使用 Unicode 字符集(严格来说是 UTF-8 编码)该字符集包含了世界上所有的字符。在 Mac OS 下ⅲⅵⅶⅸ和ⅢⅥⅦⅨ根本不会被视为字母在 Linux 下ⅲⅵⅶⅸ被视为小写字母ⅢⅥⅦⅨ被视为大写字母。站在专业角度看问题C语言标准规定在默认的C地域设置中只有 iswlower() 或者 iswupper() 返回“真”的字母才会被视为字母也就是说一个字母要么是小写字母要么是大写字母。但是对于其它的地域设置C语言并没有这种规定一个字母可以是 iswlower() 或者 iswupper() 返回“真”的字符也可以是被当前语言环境显式地(刻意地)指定为字母的字符例如罗马数字ⅲⅵⅶⅸ和ⅢⅥⅦⅨ。但是有一个原则被指定为字母的字符一定不能是 iswcntrl()、iswdigit()、iswpunct()、iswspace() 返回“真”的字符。对于 towlower()仅当有且只有一个对应的小写字母时这种转换才能成功如果没有对应的小写字母或者有多个对应的小写字母那么转换失败。转换成功返回对应的小写字母转换失败直接返回 wc(值未变)。【实例】在简体中文环境下检测大小写字母并进行转换。#include #include #include int main (){int i 0;wchar_t str[] LσωδБГЁāōūⅢⅥⅨⅲⅵⅸ;wchar_t c;setlocale(LC_ALL, zh_CN.UTF-8); //设置为简体中文使用UTF-8编码//在 Windows 下可以写作 setlocale(LC_ALL, ); 或者 setlocale(LC_ALL, chs);//在 Linux 下可以写作 setlocale(LC_ALL, ); 或者 setlocale(LC_ALL, zh_CN.UTF-8);//在 Mac OS 下可以写作 setlocale(LC_ALL, zh_CN); 或者 setlocale(LC_ALL, zh_CN.UTF-8);while (str[i]){c str[i];if (iswupper(c)) wprintf(L%lc is upper, the lower is %lc\n, c, towlower(c));else if(iswlower(c)) wprintf(L%lc is lower, the upper is %lc\n, c, towupper(c));else if(iswalpha(c)) wprintf(L%lc is alphabetic\n, c);else wprintf(L%lc is a character\n, c);i;}return 0;}在 Windows 下的运行结果σ is lower, the upper is Σω is lower, the upper is Ωδ is lower, the upper is ΔБ is upper, the lower is бГ is upper, the lower is гЁ is upper, the lower is ёis lower, the upper is āis lower, the upper is ōis lower, the upper is ūⅢ is alphabeticⅥ is alphabeticⅨ is alphabeticⅲ is alphabeticⅵ is alphabeticⅸ is alphabetic在 Linux 下的运行结果σ is lower, the upper is Σω is lower, the upper is Ωδ is lower, the upper is ΔБ is upper, the lower is бГ is upper, the lower is гЁ is upper, the lower is ёā is lower, the upper is Āō is lower, the upper is Ōū is lower, the upper is ŪⅢ is upper, the lower is ⅲⅥ is upper, the lower is ⅵⅨ is upper, the lower is ⅸⅲ is lower, the upper is Ⅲⅵ is lower, the upper is Ⅵⅸ is lower, the upper is Ⅸ在 Mac OS 下的运行结果σ is lower, the upper is Σω is lower, the upper is Ωδ is lower, the upper is ΔБ is upper, the lower is бГ is upper, the lower is гЁ is upper, the lower is ёā is lower, the upper is Āō is lower, the upper is Ōū is lower, the upper is ŪⅢ is a characterⅥ is a characterⅨ is a characterⅲ is a characterⅵ is a characterⅸ is a character