diff --git a/src/pdal/osgeo4w/patch b/src/pdal/osgeo4w/patch index c12500b3..21836f97 100644 --- a/src/pdal/osgeo4w/patch +++ b/src/pdal/osgeo4w/patch @@ -1,4 +1,3 @@ -Only in ../pdal-2.3/pdal: gitsha.cpp diff -ur PDAL-2.3-maintenance/pdal/StageExtensions.hpp ../pdal-2.3/pdal/StageExtensions.hpp --- PDAL-2.3-maintenance/pdal/StageExtensions.hpp 2021-05-28 02:51:09.000000000 +0200 +++ ../pdal-2.3/pdal/StageExtensions.hpp 2022-07-02 19:56:50.279316800 +0200 @@ -11,3 +10,54 @@ diff -ur PDAL-2.3-maintenance/pdal/StageExtensions.hpp ../pdal-2.3/pdal/StageExt std::string defaultWriter(const std::string& filename); PDAL_DLL StringList extensions(const std::string& stage); private: +diff -ur PDAL-2.3-maintenance/pdal/util/FileUtils.cpp ../pdal-2.3/pdal/util/FileUtils.cpp +--- PDAL-2.3-maintenance/pdal/util/FileUtils.cpp 2021-05-28 02:51:09.000000000 +0200 ++++ ../pdal-2.3/pdal/util/FileUtils.cpp 2022-08-03 14:33:46.326750400 +0200 +@@ -78,18 +78,38 @@ + #ifdef _WIN32 + inline std::string fromNative(std::wstring const& in) + { +- // TODO: C++11 define convert with static thread_local +- std::wstring_convert, unsigned short> convert; +- auto p = reinterpret_cast(in.data()); +- return convert.to_bytes(p, p + in.size()); ++ if (in.empty()) ++ return std::string(); ++ ++ // The first call determines the length of the conversion. The second does the ++ // actual conversion. ++ int len = WideCharToMultiByte(CP_UTF8, 0, in.data(), in.length(), nullptr, 0, nullptr, nullptr); ++ std::string out(len, 0); ++ if (WideCharToMultiByte(CP_UTF8, 0, in.data(), in.length(), const_cast( out.data() ), len, nullptr, nullptr) == 0) ++ { ++ int err = GetLastError(); ++ char buf[200] {}; ++ len = FormatMessageA(0, 0, GetLastError(), 0, buf, 199, 0); ++ throw pdal_error("Can't convert UTF16 to UTF8: " + std::string(buf, len)); ++ } ++ return out; + } + inline std::wstring toNative(std::string const& in) + { +- // TODO: C++11 define convert with static thread_local +- std::wstring_convert, unsigned short> convert; +- auto s = convert.from_bytes(in); +- auto p = reinterpret_cast(s.data()); +- return std::wstring(p, p + s.size()); ++ if (in.empty()) ++ return std::wstring(); ++ ++ // The first call determines the length of the conversion. The second does the ++ // actual conversion. ++ int len = MultiByteToWideChar(CP_UTF8, 0, in.data(), in.length(), nullptr, 0); ++ std::wstring out(len, 0); ++ if (MultiByteToWideChar(CP_UTF8, 0, in.data(), in.length(), const_cast( out.data() ), len) == 0) ++ { ++ char buf[200] {}; ++ len = FormatMessageA(0, 0, GetLastError(), 0, buf, 199, 0); ++ throw pdal_error("Can't convert UTF8 to UTF16: " + std::string(buf, len)); ++ } ++ return out; + } + #else + // inline std::string const& fromNative(std::string const& in) { return in; }