Boost logo

Boost :

Subject: Re: [boost] [filesystem] Version 3 of Boost.Filesystem added to trunk
From: Beman Dawes (bdawes_at_[hidden])
Date: 2010-06-03 20:04:26


On Thu, Jun 3, 2010 at 6:48 PM, Alexander Lamaison <awl03_at_[hidden]> wrote:
> On Wed, 2 Jun 2010 11:07:34 -0400, Beman Dawes wrote:
>>
>> * Any other comments or suggestions?
>
> Some code I have wraps a SFTP library that returns paths as UTF-8 strings.
> These need to be converted to the local code page before displaying to the
> user.  My original plan was to typedef basic_path with a traits class of my
> own that I could imbue with a specific locale to do the conversion.
>
> With FSv3 the only way to do this seems to be path::imbue() which imbue
> *all* paths, globally.  Or am I missing something?

Yep, there is another way. First convert the UTF-8 string to a UTF-16
string using software of your choice. Then construct a
boost::filesystem::path with the UTF-16 string as an argument.
Alternately, assign the UTF-16 string to a boost::filesystem::path.

Say the resulting path is named p. Then p.string() will return a
std::string containing the path in native format, native codepage.

Does that solve your problem?

--Beman


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