tolower
來自 cppreference.com
在標頭檔案 <ctype.h> 中定義 |
||
int tolower( int ch ); |
||
根據當前安裝的 C 語言環境定義的字元轉換規則,將給定字元轉換為小寫。
在預設的“C”語言環境中,以下大寫字母 ABCDEFGHIJKLMNOPQRSTUVWXYZ
被替換為相應的小寫字母 abcdefghijklmnopqrstuvwxyz
。
目錄 |
[編輯] 引數
ch | - | 要轉換的字元。如果 ch 的值不能表示為 unsigned char 且不等於 EOF,則行為未定義。 |
[編輯] 返回值
ch 的小寫版本,如果當前 C 語言環境中沒有列出小寫版本,則返回未修改的 ch。
[編輯] 示例
執行此程式碼
#include <ctype.h> #include <limits.h> #include <locale.h> #include <stdio.h> int main(void) { // In the default locale for (unsigned char u = 0; u < UCHAR_MAX; u++) { unsigned char 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 setlocale(LC_ALL, "en_US.iso88591"); printf("in iso8859-1, tolower('0x%x') gives 0x%x\n", c, tolower(c)); setlocale(LC_ALL, "en_US.iso885915"); printf("in iso8859-15, tolower('0x%x') gives 0x%x\n", c, 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
[編輯] 參考
- C23 標準 (ISO/IEC 9899:2024)
- 7.4.2.1 tolower 函式 (p: TBD)
- C17 標準 (ISO/IEC 9899:2018)
- 7.4.2.1 tolower 函式 (p: 147)
- C11 標準 (ISO/IEC 9899:2011)
- 7.4.2.1 tolower 函式 (p: 203)
- C99 標準 (ISO/IEC 9899:1999)
- 7.4.2.1 tolower 函式 (p: 184)
- C89/C90 標準 (ISO/IEC 9899:1990)
- 4.3.2.1 tolower 函式
[編輯] 另請參閱
將字元轉換為大寫 (函式) | |
(C95) |
將寬字元轉換為小寫 (函式) |
C++ 文件 中的 tolower
|