Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::towctrans

      From cppreference.com
      <cpp‎ |string‎ |wide
       
       
       
       
      Defined in header<cwctype>

      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

      [edit]Parameters

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

      [edit]Return value

      The mapped value ofch using the mapping identified bydesc inLC_CTYPE facet of the current C locale.

      [edit]Example

      The following example demonstrates katakana to hiragana character mapping.

      Run this code
      #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

      [edit]See also

      looks up a character mapping category in the current C locale
      (function)[edit]
      C documentation fortowctrans
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/string/wide/towctrans&oldid=153713"

      [8]ページ先頭

      ©2009-2025 Movatter.jp