函式
<cwctype>

wctrans

wctrans_t wctrans (const char* property);
返回字元轉換
返回一個 wctrans_t 型別的值,該值對應於 property 指定的字元轉換。

特定的 locale 可以接受多種字元轉換。至少以下轉換被所有 locale 識別:

作為 property 傳入的字串描述等效函式
"tolower"轉為小寫towlower
"toupper"轉為大寫towupper

此函式返回的值取決於LC_CTYPE 所選的 locale 類別。

引數

屬性
一個標識字元轉換的字串(參見上文)。

返回值

一個 wctrans_t 型別的值,用於標識特定的字元類別。
此值依賴於 locale。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* 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.


另見