summaryrefslogtreecommitdiff
path: root/src/win32/stringutils.cpp
blob: a82dd7aed42cf1cd7c6ccbf3a272fa252c41716a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "errormsg.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;
}