MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / DecodeUTF8Path

Function DecodeUTF8Path

utils/platform_utils.h:27–36  ·  view source on GitHub ↗

For Windows, we convert the UTF-8 path to a UTF-16 path to force using the APIs that correctly handle unicode characters.

Source from the content-addressed store, hash-verified

25// For Windows, we convert the UTF-8 path to a UTF-16 path to force using
26// the APIs that correctly handle unicode characters.
27inline std::wstring DecodeUTF8Path(std::string path) {
28 std::wstring result;
29 int len = MultiByteToWideChar(CP_UTF8, 0, path.c_str(), static_cast<int>(path.length()), NULL, 0);
30 if (len > 0)
31 {
32 result.resize(len);
33 MultiByteToWideChar(CP_UTF8, 0, path.c_str(), static_cast<int>(path.length()), &result[0], len);
34 }
35 return result;
36}
37#else
38// For other platforms there is no need for any conversion, they
39// support UTF-8 natively.

Callers 2

fopenUTF8Function · 0.70
unlinkUTF8Function · 0.70

Calls 3

c_strMethod · 0.45
lengthMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected