写文件:
#include <Windows.h> #include <iostream> #include <tchar.h> int main() { FILE *fp; fp = _tfopen(_T("d:\\sss.ini"), _T("w")); //if (fp == NULL) //{ // fp=_tfopen(_T("d:\\sss.ini"), _T("w+b")); // // wchar_t m_strUnicode[1]; // m_strUnicode[0] = wchar_t(0XFEFF); // fputwc(*m_strUnicode,fp); //} wchar_t strUn[100]; char * ptr="Hello"; int count=MultiByteToWideChar(CP_ACP,0,ptr,-1,NULL,0); wchar_t * wcA=new wchar_t[count]; //MultiByteToWideChar(CP_ACP,0,ptr,-1,wcA,count); MultiByteToWideChar(CP_UTF8, 0, ptr, count, wcA, count); fputws(wcA,fp); delete [] wcA; fclose(fp); return 0; };