std::filesystem::u8path (3) - Linux Man Pages
Defined in header <filesystem>
template< class Source > (1) (since C++17)
path u8path( const Source& source ); (deprecated in C++20)
template< class InputIt > (2) (since C++17)
path u8path( InputIt first, InputIt last ); (deprecated in C++20)
Constructs a path p from a UTF-8 encoded sequence of chars, supplied either as an std::string, or as std::string_view, or as a null-terminated multibyte string, or as a [first, last) iterator pair.
* If path::value_type is char and native encoding is UTF-8, constructs a path directly as if by path(source) or path(first, last). Note: this is the typical situation of a POSIX system that uses Unicode, such as Linux.
* Otherwise, if path::value_type is wchar_t and native encoding is UTF-16 (this is the situation on Windows), or if path::value_type is char16_t (native encoding guaranteed UTF-16) or char32_t (native encoding guaranteed UTF-32), then first converts the UTF-8 character sequence to a temporary string tmp of type path::string_type and then the new path is constructed as if by path(tmp)
* Otherwise (for non-UTF-8 narrow character encodings and for non-UTF-16 wchar_t), first converts the UTF-8 character sequence to a temporary UTF-32-encoded string tmp of type std::u32string, and then the new path is constructed as if by path(tmp) (this path is taken on a POSIX system with a non-Unicode multibyte or single-byte encoded filesystem)
source - a UTF-8 encoded std::string, std::string_view, a pointer to a null-terminated multibyte string, or an input iterator with char value type that points to a null-terminated multibyte string
first, last - pair of LegacyInputIterators that specify a UTF-8 encoded character sequence
InputIt must meet the requirements of LegacyInputIterator.
The value type of InputIt must be char
The path constructed from the input string after conversion from UTF-8 to the filesystem's native character encoding.
May throw std::bad_alloc if memory allocation fails.
On systems where native path format differs from the generic path format (neither Windows nor POSIX systems are examples of such OSes), if the argument to this function is using generic format, it will be converted to native.
// Run this code