[fs.path.construct] (original) (raw)

[Example 1:

A string is to be read from a database that is encoded in ISO/IEC 8859-1, and used to create a directory:namespace fs = std::filesystem; std::string latin1_string = read_latin1_data(); codecvt_8859_1<wchar_t> latin1_facet; std::locale latin1_locale(std::locale(), latin1_facet); fs::create_directory(fs::path(latin1_string, latin1_locale));

For POSIX-based operating systems, the path is constructed by first usinglatin1_facet to convert ISO/IEC 8859-1 encodedlatin1_string to a wide character string in the native wide encoding ([fs.path.type.cvt]).

The resulting wide string is then converted to an ordinary character pathname string in the current native ordinary encoding.

If the native wide encoding is UTF-16 or UTF-32, and the current native ordinary encoding is UTF-8, all of the characters in the ISO/IEC 8859-1 character set will be converted to their Unicode representation, but for other native ordinary encodings some characters may have no representation.

For Windows-based operating systems, the path is constructed by using latin1_facet to convert ISO/IEC 8859-1 encodedlatin1_string to a UTF-16 encoded wide character pathname string.

All of the characters in the ISO/IEC 8859-1 character set will be converted to their Unicode representation.

— _end example_]