std::towctrans(3)
π std::towctrans(3) π
okay so this is the std::towctrans(3) page from the C++ Standard Libary manual β yes, that spelling is the manualβs, bestie π«Ά β and itβs all about mapping wide characters through the current C localeβs LC_CTYPE mapping category. iconic behavior, honestly β¨
πΈ NAME πΈ
std::towctrans β std::towctrans (thatβs literally the name, no cap π
)
β¨ Synopsis β¨
Defined in header <cwctype>:
std::wint_t towctrans( std::wint_t ch, std::wctrans_t desc );
Maps the wide character ch using the current C localeβs LC_CTYPE mapping category identified by desc π
careful, bestie: if the value ofchis neither representable as awchar_tnor equal to the value of the macroWEOF, the behavior is undefined ππ
π Parameters π
chβ the wide character to map πdescβ theLC_CTYPEmapping, obtained from a call tostd::wctransβ¨
π¦ Return value π¦
The mapped value of ch using the mapping identified by desc in the LC_CTYPE facet of the current C locale. thatβs the whole vibe π«Ά
π₯ Example π₯
The following example demonstrates katakana to hiragana character mapping β literally so cute πΈ
Run this code, bestie π
#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
π See also π
wctransβ looks up a character mapping category in the current C locale (function) π- C documentation for
towctransβ¨
mwah π this page came from http://cppreference.com, dated 2024.06.10, and itβs the std::towctrans(3) page π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms