gulrak / filesystem

An implementation of C++17 std::filesystem for C++11 /C++14/C++17/C++20 on Windows, macOS, Linux and FreeBSD.
MIT License
1.31k stars 168 forks source link

More Code convertion support #152

Closed thegoodtgg closed 1 year ago

thegoodtgg commented 1 year ago

I am using ghc::filesystem on windows 10. I just can't construct ghc::filesystem::path with std::string in GBK encoding that is my encoding in locale. Because ghc::filesystem::path assumes std::string all in utf-8 encoding. Can you support codecvt in ghc::fileysystem::path constructor.

` template <class Source, typename> inline path::path(const Source& source, format fmt)

ifdef GHC_USE_WCHAR_T

: _path(detail::toWChar(source))

else

: _path(detail::toUtf8(source))

endif

{ postprocess_path_with_format(fmt); } `

template <typename strT, typename std::enable_if<path::_is_basic_string<strT>::value && (sizeof(typename strT::value_type) == 1), bool>::type = false> inline std::wstring toWChar(const strT& unicodeString) { return fromUtf8<std::wstring>(unicodeString); }

Maybe add another constructor

template<typename Source, typename CodeCvt> path(const Source &source, const CodeCvt &codeCvt, format format)

And I am considering using boost::filesystem instead.

gulrak commented 1 year ago

I'm sorry, ghc::filesystem really is Unicode-centric utf8-everywhere motivated and documented as such. I don't have the resources to test for all the non-Unicode setups out there, as it is a single-dev project in my free time, and making changes I can't test to work is problematic for me.

thegoodtgg commented 1 year ago

Thank you for your reply. I admire your wonderful work and your choice is right. I am using boost::filesystem instead. Please close the issue.