std:: towctrans
| 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 | ||||||||||||||||||||||||||
|
ヘッダーで定義
<cwctype>
|
||
|
std::
wint_t
towctrans
(
std::
wint_t
ch,
std::
wctrans_t
desc
)
;
|
||
ワイド文字 ch を、現在のCロケールの LC_CTYPE マッピングカテゴリを使用して、 desc で指定された方法でマッピングします。
ch の値が wchar_t として表現可能でなく、かつマクロ WEOF の値とも等しくない場合、動作は未定義です。
目次 |
パラメータ
| ch | - | マッピングするワイド文字 |
| desc | - | LC_CTYPE マッピング。 std::wctrans の呼び出しから取得 |
戻り値
ch のマッピングされた値。これは、現在のCロケールの LC_CTYPE ファセット内で desc によって識別されるマッピングを使用します。
例
以下の例は、カタカナからひらがなへの文字マッピングを示しています。
#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"; }
出力:
katakana characters ヒラガナ are ひらがな in hiragana
関連項目
|
現在のCロケールで文字マッピングカテゴリを検索する
(関数) |
|
|
Cドキュメント
for
towctrans
|
|