Boost logo

Boost :

Subject: Re: [boost] [review] Review of Nowide (Unicode) starts today
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2017-06-16 07:40:24


> The encoding is defined by current Locale that can be defined
> globally, per user,
> per process and even change trivially in the same process during the runtime.
> They are all can be changed at runtime, they aren't synchronized and
> they be modified to whatever encoding user wants.
>
> So the safest and the most correct way to handle it is to pass narrow
> strings as is
> without any conversion.

I understand that this complexity can be a nightmare.

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) /
file_name).string());

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

On Posix, there is a risk that base_dir is for example ISO-8859-1
while file_name is UTF-8 so that the combination made by filesystem is
wrong.
Am I right?

Frédéric


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk