C参考手册
字符串 | Strings
tolower
在头文件<ctype.h>中定义 |
|
|
---|---|---|
int tolower(int ch); |
|
|
根据当前安装的C语言环境定义的字符转换规则将给定字符转换为小写字母。
在默认的“C”语言环境中,下列大写字母ABCDEFGHIJKLMNOPQRSTUVWXYZ
被替换为相应的小写字母abcdefghijklmnopqrstuvwxyz
。
参数
CH |
- |
字符被转换。如果ch的值不能表示为unsigned char并且不等于EOF,则行为是未定义的。 |
---|
返回值
如果在当前C语言环境中未列出小写版本,则ch或未修改ch的小写版本。
例
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <limits.h>
int main(void)
{
/* In the default locale: */
unsigned char l;
for (unsigned char u=0; u<UCHAR_MAX; u++) {
l = tolower(u);
if (l!=u) printf("%c%c ", u,l);
}
printf("\n\n");
unsigned char c = '\xb4'; // the character Ž in ISO-8859-15
// but ´ (acute accent) in ISO-8859-1
unsigned char c2 = c; // for printing
setlocale(LC_ALL, "en_US.iso88591");
printf("in iso8859-1, tolower('0x%x') gives 0x%x\n", c2, tolower(c));
setlocale(LC_ALL, "en_US.iso885915");
printf("in iso8859-15, tolower('0x%x') gives 0x%x\n", c2, tolower(c));
}
输出:
Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz
in iso8859-1, tolower('0xb4') gives 0xb4
in iso8859-15, tolower('0xb4') gives 0xb8
参考
- C11标准(ISO / IEC 9899:2011):
- 7.4.2.1托利功能(p:203)
- C99标准(ISO / IEC 9899:1999):
- 7.4.2.1托利功能(p:184)
- C89 / C90标准(ISO / IEC 9899:1990):
- 4.3.2.1托利功能
扩展内容
TOUPPER |
将字符转换为大写(函数) |
---|---|
towlower (C95) |
将宽字符转换为小写(函数) |
| tolower的C ++文档 |