| 66 | } |
| 67 | |
| 68 | const std::string GetUTF8DataDir () { |
| 69 | #ifdef _WIN32 |
| 70 | int size = MultiByteToWideChar(CP_ACP, 0, |
| 71 | dataDir.c_str(), dataDir.size(), nullptr, 0); |
| 72 | std::wstring utf16Str(size, L'\0'); |
| 73 | MultiByteToWideChar(CP_ACP, 0, |
| 74 | dataDir.c_str(), dataDir.size(), &utf16Str[0], size); |
| 75 | int utf8Size = WideCharToMultiByte(CP_UTF8, 0, |
| 76 | utf16Str.c_str(), utf16Str.size(), nullptr, 0, nullptr, nullptr); |
| 77 | std::string utf8Str(utf8Size, '\0'); |
| 78 | WideCharToMultiByte(CP_UTF8, 0, |
| 79 | utf16Str.c_str(), utf16Str.size(), &utf8Str[0], utf8Size, nullptr, nullptr); |
| 80 | return utf8Str; |
| 81 | #else |
| 82 | return dataDir; // linux, osx, android uses UTF-8 by default |
| 83 | #endif |
| 84 | } |
| 85 | |
| 86 | void DetectDataDir(const std::string & cmdline_param, bool isService) { |
| 87 | // with 'datadir' option |