最終更新日時:
が更新

履歴 編集

function
<locale>

std::ctype::widen

charT
  widen(char c) const;     // (1) C++98

const char*
  widen(const char* low,
        const char* high,
        charT* to) const;  // (2) C++98

概要

指定されたchar型の文字に該当するcharT型の文字を取得する。

  • (1) : 文字ccharT型へ変換する
  • (2) : 範囲[low, high)の各文字をcharT型へ変換し、toが指す領域へ格納する

戻り値

#include <iostream>
#include <locale>

int main()
{
  const auto& ct = std::use_facet<std::ctype<wchar_t>>(std::locale::classic());

  // (1)
  std::wcout << ct.widen('a') << std::endl;

  // (2)
  const char s[] = "abc";
  wchar_t buf[4] = {};
  ct.widen(s, s + 3, buf);

  std::wcout << buf << std::endl;
}

出力

a
abc

バージョン

言語

  • C++98

関連項目