最終更新日時(UTC):
が更新

履歴 編集

function
<filesystem>

std::filesystem::path::system_encoded_string(C++26)

std::string system_encoded_string() const;

概要

OS依存のパス名エンコーディング (システムのマルチバイト文字コード) で、パス文字列を取得する。

戻り値

native()を返す。

文字コード変換が必要な場合、その変換は<filesystem>のパス変換規則に従って行われる。

備考

  • 文字コード変換は損失をともなう可能性があるため、この関数で取得した文字列はレガシーなシステムAPIにパスを渡す用途にのみ適している
  • 表示やフォーマットの用途では、display_string()std::format()std::print()を使用すること

#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;

int main()
{
  fs::path p = "/usr/bin/clang";

  std::string s = p.system_encoded_string();
  std::cout << s << std::endl;
}

出力

/usr/bin/clang

バージョン

言語

  • C++26

処理系

関連項目

参照