| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||
| Character classification | ||||||||||||||||||||||||||
| Character manipulation | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
| Conversions to numeric formats | ||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||
| String manipulation | ||||||||||||||||||||||||||
| String examination | ||||||||||||||||||||||||||
| Array manipulation | ||||||||||||||||||||||||||
Defined in header <cwctype> | ||
std::wint_t towctrans(std::wint_t ch,std::wctrans_t desc); | ||
Maps the wide characterch using the current C locale'sLC_CTYPE mapping category identified bydesc.
If the value ofch is neither representable as awchar_t nor equal to the value of the macroWEOF, the behavior is undefined.
Contents |
| ch | - | the wide character to map |
| desc | - | theLC_CTYPE mapping, obtained from a call tostd::wctrans |
The mapped value ofch using the mapping identified bydesc inLC_CTYPE facet of the current C locale.
The following example demonstrates katakana to hiragana character mapping.
#include <algorithm>#include <clocale>#include <cwctype>#include <iostream> 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";}
Output:
katakana characters ヒラガナ are ひらがな in hiragana
| looks up a character mapping category in the current C locale (function)[edit] | |
C documentation fortowctrans | |