]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/filesystem/src/windows_file_codecvt.cpp
1 // filesystem windows_file_codecvt.cpp -----------------------------------------//
3 // Copyright Beman Dawes 2009
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 // Library home page: http://www.boost.org/libs/filesystem
10 //--------------------------------------------------------------------------------------//
12 #include "platform_config.hpp"
14 #include <cwchar> // for mbstate_t
16 #ifdef BOOST_WINDOWS_API
18 #include "windows_file_codecvt.hpp"
23 namespace filesystem
{
26 std::codecvt_base::result
windows_file_codecvt::do_in(
28 const char* from
, const char* from_end
, const char*& from_next
,
29 wchar_t* to
, wchar_t* to_end
, wchar_t*& to_next
) const
31 UINT codepage
= AreFileApisANSI() ? CP_ACP
: CP_OEMCP
;
34 if ((count
= ::MultiByteToWideChar(codepage
, MB_PRECOMPOSED
, from
, static_cast< int >(from_end
- from
), to
, static_cast< int >(to_end
- to
))) == 0)
36 return error
; // conversion failed
45 std::codecvt_base::result
windows_file_codecvt::do_out(
47 const wchar_t* from
, const wchar_t* from_end
, const wchar_t*& from_next
,
48 char* to
, char* to_end
, char*& to_next
) const
50 UINT codepage
= AreFileApisANSI() ? CP_ACP
: CP_OEMCP
;
53 if ((count
= ::WideCharToMultiByte(codepage
, WC_NO_BEST_FIT_CHARS
, from
, static_cast< int >(from_end
- from
), to
, static_cast< int >(to_end
- to
), 0, 0)) == 0)
55 return error
; // conversion failed
65 } // namespace filesystem
68 #endif // BOOST_WINDOWS_API