當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


C語言 wctrans用法及代碼示例

C語言wctype頭文件(wctype.h)中wctrans函數的用法及代碼示例。

用法:

wctrans_t wctrans (const char* property);
返回字符轉換
返回類型的值wctrans_t對應於字符轉換屬性

特定的語言環境可以接受字符的多種轉換。至少所有區域設置都可以識別以下轉換:

字符串作為屬性描述等效函數
"tolower"小寫towlower
"toupper"大寫towupper

此函數返回的值取決於LC_CTYPE locale選擇的類別。

參數

property
標識字符轉換的字符串(請參見上文)。

返回值

類型值wctrans_t識別特定的字符類別。
此值為locale-dependent。

示例

/* wctrans example */
#include <stdio.h>
#include <wctype.h>
int main ()
{
  int i=0;
  wchar_t str[] = L"Test String.\n";
  wchar_t c;
  wctype_t check = wctype("lower");
  wctrans_t trans = wctrans("toupper");
  while (str[i])
  {
    c = str[i];
    if (iswctype(c,check)) c = towctrans(c,trans);
    putwchar (c);
    i++;
  }
  return 0;
}


輸出:
TEST STRING.

相關用法


注:本文由純淨天空篩選整理自C標準庫大神的英文原創作品 C wctrans function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。