std::towctrans

Header: <cwctype>

Maps the wide character ch using the current C locale’s LC_CTYPE mapping category identified by desc.

# Declarations

std::wint_t towctrans( std::wint_t ch, std::wctrans_t desc );

# Parameters

# Return value

The mapped value of ch using the mapping identified by desc in LC_CTYPE facet of the current C locale.

# Example

#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";
}

# See also