TEST FOUR - _wfopen + UTF-8 -> 16 conversion
Finally:
using std::wstring;
wstring
toWideString( const char* pStr , int len )
{
// figure out how many wide characters we are going to get
int nChars = MultiByteToWideChar( CP_ACP , 0 , pStr , len , NULL , 0 ) ;
if ( len == -1 )
-- nChars ;
if ( nChars == 0 )
return L"" ;
wstring buf ;
buf.resize( nChars ) ;
MultiByteToWideChar( CP_ACP , 0 , pStr , len ,
const_cast<wchar_t*>(buf.c_str()) , nChars ) ;
return buf ;
}
int _tmain(int argc, _TCHAR* argv[])
{
wstring wname = toWideString(name, strlen(name));
FILE* x = _wfopen(wname.c_str(), (const wchar_t*)"wb");
return 0;
}
äºéƒ½å¸‚#
(random junk)