Skip to content

Latest commit

 

History

History
71 lines (53 loc) · 1.39 KB

File metadata and controls

71 lines (53 loc) · 1.39 KB

generic_u16string

  • filesystem[meta header]
  • std::filesystem[meta namespace]
  • path[meta class]
  • function[meta id-type]
  • cpp17[meta cpp]
std::u16string generic_u16string() const;

概要

UTF-16エンコードで、環境非依存パスフォーマットのパス文字列を取得する。

戻り値

*thisが保持するシステムの環境非依存パスフォーマットを持つパスを、UTF-16エンコードで返す。

POSIXベースシステムでの例

#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;

int main()
{
  fs::path p = "/usr/bin/clang";
  const std::u16string s = p.generic_u16string();
}
  • p.generic_u16string()[color ff0000]

出力

Windowsでの例

#include <cassert>
#include <filesystem>

namespace fs = std::filesystem;

int main()
{
  fs::path p = "foo\\bar";
  const std::u16string s = p.generic_u16string();
  assert(s == u"foo/bar");
}
  • p.generic_u16string()[color ff0000]

出力

Windowsでの例は、Visual C++が正式にファイルシステムライブラリをサポートしていないことから、未検証のサンプルコード・出力となっている。

バージョン

言語

  • C++17

処理系