1. In mac environments, since the mac file opening function originally supports utf8 character paths, you can directly input Chinese characters without modifying the third-party library code.
2. Because windows functions do not support utf8 characters, you need to modify the third-party library code.
Modification method:
1. Find all the places where fopen is used in the third-party library. If these files reference the same file, you can add a macro to the file to replace fopen (). The Code is as follows:
. H
#ifdef _WIN32std::wstring Utf8ToUnicode(const char* buf);#define fopen(a, b) _wfopen(Utf8ToUnicode(a).c_str(), Utf8ToUnicode(b).c_str())#endif
. Cpp
#ifdef _WIN32#include <Windows.h>#include <vector>std::wstring Utf8ToUnicode(const char* buf){ int len = ::MultiByteToWideChar(CP_UTF8, 0, buf, -1, NULL, 0); if (len == 0) { return L""; } std::vector<wchar_t> unicode(len); ::MultiByteToWideChar(CP_UTF8, 0, buf, -1, &unicode[0], len); return &unicode[0];}#endif
Windows character conversion functions can refer to: http://www.cnblogs.com/gakusei/articles/1585211.html