static std::string w2c(std::wstring str)
{
int nlength = str.length();
int nbytes = WideCharToMultiByte(0,0,str.c_str(),nlength,NULL,0,NULL,NULL);
if(nbytes == 0) return "";

char*buff = new char[nbytes+1];
WideCharToMultiByte(0,0,str.c_str(),nlength,buff,nbytes,NULL,NULL);
buff[nbytes] = '\0';
std::string ret_str = std::string(buff);
delete [] buff;
return ret_str;
}

static std::wstring c2w(std::string str)
{
if(str.length() == 0) return std::wstring();

int nu = str.length();
size_t n =(size_t)MultiByteToWideChar(CP_ACP,0,str.c_str(),nu,NULL,0);
wchar_t*wbuff = new wchar_t[n+1];
MultiByteToWideChar(CP_ACP,0,str.c_str(),(int)nu,wbuff,(int)n);
wbuff[n] = 0;

std::wstring wstr_ret = std::wstring(wbuff);
delete []wbuff;
return wstr_ret;
}