MCPcopy Create free account
hub / github.com/PDAL/PDAL / fromNative

Function fromNative

pdal/util/FileUtils.cpp:110–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110std::string fromNative(const std::wstring& in)
111{
112 if (in.empty())
113 return std::string();
114
115 // The first call determines the length of the conversion. The second does the
116 // actual conversion.
117 int len = WideCharToMultiByte(CP_UTF8, 0, in.data(), in.length(), nullptr, 0, nullptr, nullptr);
118 std::string out(len, 0);
119 if (WideCharToMultiByte(CP_UTF8, 0, in.data(), in.length(), out.data(), len,
120 nullptr, nullptr) == 0)
121 {
122 int err = GetLastError();
123 char buf[200] {};
124 len = FormatMessageA(0, 0, GetLastError(), 0, buf, 199, 0);
125 throw pdal_error("Can't convert UTF16 to UTF8: " + std::string(buf, len));
126 }
127 return out;
128}
129#else // Unix, OSX, MinGW
130std::string toNative(const std::string& in)
131{

Callers 3

mainFunction · 0.85
dllDirFunction · 0.85
globFunction · 0.85

Calls 3

emptyMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected