Boost logo

Boost :

Subject: Re: [boost] [review] Review of Nowide (Unicode) starts today
From: Artyom Beilis (artyom.beilis_at_[hidden])
Date: 2017-06-16 09:27:26

How would you therefore do this simple task:
1. get a directory from nowide::getenv -> base_dir (UTF-8 on Windows,
unknown narrow on Posix)
2. create a file in base_dir which name is file_name encoded in UTF-8
(because it is created by the application).

If I understand well, I should NOT do this:

auto f = nowide::ofstream((boost::filesystem::path(base_dir) /

because this is guaranteed to work only on Windows where I have the
guarantee that base_dir is UTF-8, right?

Actually it is what exactly you should do. Once you turn on **nowide
integration** with boost filesystem

path::string does not perform any conversions on POSIX platforms.

And you can safely concatenate two different strings and valid file will be
created. Even if dir is in ISO 8859-1 and file in UTF-8. The file will be
valid even if not representable in any encoding.

Under windows you'll get the correct conversions from narrow to wide using
the utf8/16 facet installed by boost.nowide/Filesystem integration as on
Windows boost filesystem uses wide strings


Boost list run by bdawes at, gregod at, cpdaniel at, john at