From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2022-08-15 21:56:17
On 8/16/22 00:10, Peter Dimov via Boost wrote:
> Andrey Semashev wrote:
>> On 8/15/22 22:35, Peter Dimov via Boost wrote:
>>> Vinnie Falco wrote:
>>>> On Mon, Aug 15, 2022 at 11:28 AM Peter Dimov via Boost
>>>> <boost_at_[hidden]> wrote:
>>>>> That's why I think that the only sensible interpretation of paths
>>>>> coming from URLs is as UTF-8, and for this case, the default
>>>>> filesystem conversion isn't suitable.
>>>> Can you please submit a pull request showing me how route.cpp can be
>>>> correctly implemented according to these semantics?
>>> The usual approach is to put
>>> boost::filesystem::path::imbue( std::locale( std::locale::classic(),
>>> new boost::filesystem::detail::utf8_codecvt_facet ) );
>> I'd rather
>> Don't recommend users to use stuff from namespace detail. :)
> Sound advice in principle but that's pretty much the established practice
> at this point. Perhaps we should expose a non-detail way to perform the
> above, such as provide a function "set_utf8_as_default".
Perhaps, move utf8_codecvt_facet to Utility or Core?
>> Note though that after that call all narrow strings you pass to filesystem::path
>> must be UTF-8; you should be careful if you obtain paths from user input, files,
>> network, etc.
> Right. That's why I alluded to the alternative, using the codecvt_type overloads.
For completeness, here's a usage example:
void append_utf8(std::string const& str, fs::path& p)
std::locale loc = boost::locale::generator()("C.UTF-8");
Same with iterators.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk