std::experimental::filesystem::path:: string,wstring,u8string,...
|
template
<
class
CharT,
class
Traits
=
std::
char_traits
<
CharT
>
,
class
Alloc
=
std::
allocator
<
CharT
>
>
|
(1) | (파일시스템 TS) |
| (2) | (파일시스템 TS) | |
|
std::
string
string
(
)
const
;
|
||
|
std::
wstring
wstring
(
)
const
;
|
||
|
std::
string
u8string
(
)
const
;
|
||
|
std::
u16string
u16string
(
)
const
;
|
||
|
std::
u32string
u32string
(
)
const
;
|
||
네이티브 경로명 형식으로 변환된 내부 경로명을 특정 문자열 타입으로 반환합니다. 변환이 필요한 경우, todo 에서 지정됩니다.
u8string()
의 경우 인코딩은 항상 UTF-8입니다.
목차 |
매개변수
(없음)
반환값
네이티브 경로명 형식의 내부 경로명을 지정된 문자열 타입으로 변환합니다.
예외
구현 정의 예외를 던질 수 있습니다.
예제
#include <clocale> #include <cstdio> #include <experimental/filesystem> #include <fstream> #include <iostream> namespace fs = std::experimental::filesystem; int main() { std::setlocale(LC_ALL, "en_US.utf8"); std::locale::global(std::locale("en_US.utf8")); fs::path p = fs::u8path(u8"要らない.txt"); // 네이티브 문자열 표현은 OS API와 함께 사용 가능 std::ofstream(p) << "File contents"; // 이는 operator string()을 사용함 if (std::FILE* f = std::fopen(p.c_str(), "r")) { int ch; while ((ch=fgetc(f))!= EOF) putchar(ch); std::fclose(f); } // 멀티바이트 및 와이드 표현은 출력에 사용 가능 std::cout.imbue(std::locale()); std::cout << "\nFile name in narrow multibyte encoding: " << p.string() << '\n'; std::wcerr.imbue(std::locale()); std::wcerr << "File name in wide encoding: " << p.wstring() << '\n'; fs::remove(p); }
가능한 출력:
File contents File name in narrow multibyte encoding: 要らない.txt File name in wide encoding: 要らない.txt
참고 항목
|
경로를 일반 경로명 형식으로 변환한 문자열을 반환합니다
(public member function) |