12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include "stdafx.h"
- #include "BaseFun.h"
- #include "array.h"
- #ifdef RVC_OS_WIN
- #include <ShlDisp.h>
- #include <direct.h>
- #include <io.h>
- #include <string.h>
- #else
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- #endif // RVC_OS_WIN
- #ifndef RVC_MAX_INI_LEN
- #define RVC_MAX_INI_LEN 1024*16
- #endif // !RVC_MAX_INI_LEN
- void StringToWstring(std::wstring& szDst, std::string str)
- {
- #ifdef RVC_OS_WIN
- std::string temp = str;
- int len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)temp.c_str(), -1, NULL, 0);
- wchar_t* wszUtf8 = new wchar_t[len + 1];
- memset(wszUtf8, 0, len * 2 + 2);
- MultiByteToWideChar(CP_ACP, 0, (LPCSTR)temp.c_str(), -1, (LPWSTR)wszUtf8, len);
- szDst = wszUtf8;
- std::wstring r = wszUtf8;
- delete[] wszUtf8;
- #else
- setlocale(LC_ALL, "chs");
- const char* _Source = str.c_str();
- size_t _Dsize = str.size() + 1;
- wchar_t* _Dest = new wchar_t[_Dsize];
- wmemset(_Dest, 0, _Dsize);
- mbstowcs(_Dest, _Source, _Dsize);
- std::wstring result = _Dest;
- delete[]_Dest;
- setlocale(LC_ALL, "C");
- szDst = result;
- #endif
- }
|