Boost logo

Boost :

From: Eric MALENFANT (Eric.Malenfant_at_[hidden])
Date: 2008-01-25 09:34:48


Alexei Alexandrov, le 25 janvier 2008 07:11:
>
> namespace fs = boost::filesystem;
> int main()
> {
> // Setting the global locale to be environment locale
> std::locale::global(std::locale(""));
>
> // Setting the wpath locale to be global
> fs::wpath_traits::imbue(std::locale());
>
> fs::wpath mypath(L"/tmp/some/directory");
> fs::create_directories(mypath);
> }
>
> To me, this work looks correct and should work.
> But it terminates with the following message:
>
> terminate called after throwing an instance of
> 'boost::filesystem::basic_filesystem_error<
> boost::filesystem::basic_path<std::basic_string<wchar_t,
> std::char_traits<wchar_t>, std::allocator<wchar_t> >,
> boost::filesystem::wpath_traits> >'
> what(): boost::filesystem::wpath::to_external conversion error
> Aborted
>
> At the same time, the following code works:

[snip: Same program as above, using fs::detail::utf8_codecvt_facet instead of the system's locale]

> which uses a UTF-8 facet from boost itself.
>
> The first example should work too - this is my understanding. Who is
> wrong here - me or boost?

... or your platform's implementation of codecvt?

This is a wild guess as I don't know anything about your platform (in particular: which implementation of the standard library, and the locale environment variables used when running your program)

Éric Malenfant
---------------------------------------------
Quidquid latine dictum sit, altum viditur.


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