在线文档教程
C++
字符串 | Strings

std::towctrans

性病:

Defined in header
std::wint_t towctrans( std::wint_t wc, std::wctrans_t desc

映射宽字符wc使用当前C语言环境%27 s LC[医]识别的C型映射类别desc...

参数

ch-the wide character to map
desc-the LC_CTYPE mapping, obtained from a call to std::wctrans

返回值

的映射值ch使用desc在LC中[医]当前C语言环境的类型面。

下面的示例演示katakana到hiragana字符映射。

二次

#include <clocale> #include <cwctype> #include <iostream> #include <algorithm> std::wstring tohira(std::wstring str) { std::transform(str.begin(), str.end(), str.begin(), [](wchar_t c) { return std::towctrans(c, std::wctrans("tojhira") } return str; } int main() { std::setlocale(LC_ALL, "ja_JP.UTF-8" std::wstring kana = L"ヒラガナ"; std::wcout << "katakana characters " << kana << " are " << tohira(kana) << " in hiragana\n"; }

二次

产出:

二次

katakana characters ヒラガナ are ひらがな in hiragana

二次

另见

wctranslooks up a character mapping category in the current C locale (function)

C运输文件

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/string/Wide/Towctransc