diff options
Diffstat (limited to 'src/libcrawler/win32/stringutils.cpp')
-rwxr-xr-x | src/libcrawler/win32/stringutils.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libcrawler/win32/stringutils.cpp b/src/libcrawler/win32/stringutils.cpp new file mode 100755 index 0000000..607735c --- /dev/null +++ b/src/libcrawler/win32/stringutils.cpp @@ -0,0 +1,21 @@ +#include "win32/stringutils.hpp" + +using namespace std; + +#define WIN32_MEAN_AND_LEAN +#include <windows.h> + +std::wstring s2ws( const std::string &s ) +{ + // get size for buffer and allocate it + int len; + int slength = (int)s.length( )+1; + len = MultiByteToWideChar( CP_ACP, 0, s.c_str( ), slength, 0, 0 ); + wchar_t *buf = new wchar_t[len]; + + // convert + MultiByteToWideChar( CP_ACP, 0, s.c_str( ), slength, buf, len ); + std::wstring res( buf ); + delete[] buf; + return res; +} |