最終更新日時:
が更新

履歴 編集

function
<locale>

std::codecvt::in

result in(stateT& state,
          const externT* from,
          const externT* from_end,
          const externT*& from_next,
          internT* to,
          internT* to_end,
          internT*& to_next) const; // (1) C++98

概要

外部型の文字列を内部型の文字列へ変換する。

戻り値

do_in(state, from, from_end, from_next, to, to_end, to_next)

#include <iostream>
#include <locale>
#include <cwchar>

int main()
{
  using codecvt_t = std::codecvt<wchar_t, char, std::mbstate_t>;
  const auto& cv = std::use_facet<codecvt_t>(std::locale::classic());

  const char from[] = "abc";
  wchar_t to[4] = {};

  std::mbstate_t state{};
  const char* from_next = nullptr;
  wchar_t* to_next = nullptr;

  codecvt_t::result r = cv.in(state, from, from + 3, from_next, to, to + 3, to_next);

  *to_next = L'\0';
  std::cout << std::boolalpha << (r == codecvt_t::ok) << std::endl;
  std::wcout << to << std::endl;
}

出力

true
abc

バージョン

言語

  • C++98

関連項目