|
Boost : |
Subject: Re: [boost] [nowide] Request for interest (nowide unicode support for windows)
From: Artyom (artyomtnk_at_[hidden])
Date: 2010-06-17 15:22:57
Thats what Alexander Lamaison was talking about. And I like it.
Even I would prefer that UTF-8 would be default. But does not
mind require imbuing UTF-8 facet to locale.
Small points:
- This would not work on MinGW and many other compilers/standard
libraries as they do not have wide overload for filebuf::open.
- boost::details::utf8_codecvt... Does not support UTF-16 only
UCS-2 so it would not work correctly on characters outside
of BMP.
But this is rather limitation of standard and problem in Boost's
implementation of this facet.
Still not sure if it is possible to implement this facet correctly
in terms of definition of standard.
But my code in nowide implements filebuf that uses "FILE *" and
so it can be opened with "_wfopen"
I think it can be adopted to Boost.Filesystem.
Artyom
--- On Thu, 6/17/10, Beman Dawes <bdawes_at_[hidden]> wrote:
> From: Beman Dawes <bdawes_at_[hidden]>
> Subject: Re: [boost] [nowide] Request for interest (nowide unicode support for windows)
> To: "boost" <boost_at_[hidden]>
> Date: Thursday, June 17, 2010, 9:52 PM
> I thought some actual code might be
> of interest. Attached is a
> screenshot showing that the code worked as expected with
> VC++ 9.0.
>
> --Beman
>
> #include <boost/filesystem/fstream.hpp>
> #include
> <boost/filesystem/detail/utf8_codecvt_facet.hpp>
> #include <iostream>
>
> #define BOOST_FILESYSTEM_VERSION 3
>
> int main()
> {
>  // "ש×××" is "hello" in Hebrew; thanks to Artyom
> for the example
>
> Â std::locale global_loc = std::locale();
> Â std::locale loc(global_loc, new
> boost::filesystem::detail::utf8_codecvt_facet);
> Â std::locale old_loc =
> boost::filesystem::path::imbue(loc);
>
>  boost::filesystem::ofstream f("ש×××.narrow");
>
> Â return 0;
> }
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk