to 函式
每個到的函式和其相關的巨集,如果有的話,單一字元另一個字元轉換。
|
備註
到函式和巨集轉換如下。
常式 |
巨集 |
描述 |
---|---|---|
__toascii |
__toascii |
將轉換c為 ASCII 字元 |
tolower |
tolower |
將轉換c為小寫,必要時 |
_tolower |
_tolower |
將轉換c為小寫 |
towlower |
None |
將轉換c到相對應的寬字元小寫字母 |
toupper |
toupper |
將轉換c為大寫,必要時 |
_toupper |
_toupper |
將轉換c為大寫 |
towupper |
None |
將 c 轉換成相對應的寬字元大寫字母 |
若要使用的函式版本到也被定義為巨集的常式、 移除與巨集定義#undef指示詞或不含 CTYPE。H.如果您使用 /Za 編譯器選項時,編譯器會使用的功能版本toupper或tolower。宣告的toupper和tolower函式是在 STDLIB 中。H.
__toascii所有的日常集合,但是低序位 7 位元的c為 0,以便轉換的值表示與 ASCII 字元集中的字元。如果c已經表示 ASCII 字元, c不變。
The tolower and toupper routines:
依存於LC_CTYPE類別目前的地區設定 (tolower呼叫isupper和toupper呼叫islower)。
轉換c如果c代表轉換的代號,在目前的地區設定適當的大小寫和相反的情況下確實存在的地區設定。否則, c不變。
The _tolower and _toupper routines:
地區設定無關,還要快上許多版本的tolower和 toupper。
Can be used only when isascii(c) and either isupper(c) or islower(c), respectively, are nonzero.
如果有未定義結果c不是 ASCII 字母轉換為適當的大小寫。
towlower和towupper函數會傳回轉換的複本的c只有在下列情況皆為非零值。否則, c不變。
c適當的大小寫的是寬字元 (也就是其iswupper或 iswlower, ,不是零)。
沒有對應的寬字元的目標大小寫 (也就是其iswlower或 iswupper, ,不是零)。
範例
// crt_toupper.c
/* This program uses toupper and tolower to
* analyze all characters between 0x0 and 0x7F. It also
* applies _toupper and _tolower to any code in this
* range for which these functions make sense.
*/
#include <ctype.h>
#include <string.h>
char msg[] = "Some of THESE letters are Capitals.";
char *p;
int main( void )
{
printf( "%s\n", msg );
/* Reverse case of message. */
for( p = msg; p < msg + strlen( msg ); p++ )
{
if( islower( *p ) )
putchar( _toupper( *p ) );
else if( isupper( *p ) )
putchar( _tolower( *p ) );
else
putchar( *p );
}
}