wctrans

确定一组字符代码到另一组之间的映射。

语法

wctrans_t wctrans(
   const char *property
);

参数

property
指定一个有效转换的字符串。

返回值

如果当前区域设置的 LC_CTYPE 类别未定义其名称与属性字符串 property 匹配的映射,则函数将返回零。 否则,它将返回一个适合用作对 towctrans 的后续调用的第二个参数的非零值。

注解

此函数确定一组字符代码到另一组之间的映射。

以下调用对在所有区域设置中具有相同的行为(但可以定义更多映射,甚至在“C”区域设置中):

函数 与以下项相同
tolower(c) towctrans(c, wctrans("towlower"))
towupper(c) towctrans(c, wctrans("toupper"))

要求

例程 必需的标头
wctrans <wctype.h>

有关兼容性的详细信息,请参阅 兼容性

示例

// crt_wctrans.cpp
// compile with: /EHsc
// This example determines a mapping from one set of character
// codes to another.

#include <wchar.h>
#include <wctype.h>
#include <stdio.h>
#include <iostream>

int main()
{
    wint_t c = 'a';
    printf_s("%d\n",c);

    wctrans_t i = wctrans("toupper");
    printf_s("%d\n",i);

    wctrans_t ii = wctrans("towlower");
    printf_s("%d\n",ii);

    wchar_t wc = towctrans(c, i);
    printf_s("%d\n",wc);
}
97
1
0
65

另请参阅

数据转换
setlocale_wsetlocale