For Windows, we convert the UTF-8 path to a UTF-16 path to force using the APIs that correctly handle unicode characters.
| 3141 | // For Windows, we convert the UTF-8 path to a UTF-16 path to force using |
| 3142 | // the APIs that correctly handle unicode characters. |
| 3143 | inline std::wstring |
| 3144 | DecodeUTF8Path(std::string path) { |
| 3145 | std::wstring result; |
| 3146 | int len = |
| 3147 | MultiByteToWideChar(CP_UTF8, 0, path.c_str(), static_cast<int>(path.length()), NULL, 0); |
| 3148 | if (len > 0) { |
| 3149 | result.resize(len); |
| 3150 | MultiByteToWideChar(CP_UTF8, 0, path.c_str(), static_cast<int>(path.length()), &result[0], |
| 3151 | len); |
| 3152 | } |
| 3153 | return result; |
| 3154 | } |
| 3155 | #else |
| 3156 | // For other platforms there is no need for any conversion, they |
| 3157 | // support UTF-8 natively. |
no test coverage detected