The solution is as follows:
(1) convert the Written string into ANSI
Char * pbuffer = NULL; long lbuffersize; lbuffersize = widechartomultibyte (cp_acp, wc_no_best_fit_chars, m_srtf,-1, null, 0, null, null ); pbuffer = new char [lbuffersize + 1]; widechartomultibyte (cp_acp, wc_no_best_fit_chars, m_srtf,-1, pbuffer, lbuffersize + 1, null, null ); cfile file (_ T ("E: //. rtf "), cfile: modecreate | cfile: modewrite); file. write (pbuffer, lbuffersize); file. close ();
</PRE> <PRE name = "code" class = "CPP"> <span style = "font-size: 24px;"> (2) call the following function before writing: </span>
<Span style = "font-size: 24px;"> </span>
</PRE> <PRE name = "code" class = "CPP"> <span style = "white-space: pre "> </span> char * old_locale = _ strdup (setlocale (lc_ctype, null); setlocale (lc_ctype," CHS ");
</PRE> <PRE name = "code" class = "CPP"> <span style = "font-size: 24px;"> (3) and call the following function after writing: </span>
<Span style = "white-space: pre"> </span> setlocale (lc_ctype, old_locale); free (old_locale); // restore region settings
Cstdiofile: writestring cannot be written into Chinese