: 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 using
latin1_facet to convert ISO/IEC 8859-1 encoded
latin1_string to a wide character string in the native wide
encoding (
[fs.def.native.encode])
. The resulting wide string is then
converted to a narrow character
pathname string in the current native narrow encoding
. If the
native wide encoding is UTF-16 or UTF-32, and the current native narrow
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
narrow 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 encoded
latin1_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