Prev: Please use wxWidgets
Next: How to get crash dump when a unhandled CException is thrown bya MFC app
From: Yoavo on 11 Jan 2010 04:30 Hi, I am trying to write a Unicode string using the method WritePrivateProfileString, but it writes the string as ascii only. How do I change the method's behavior to work Unicode? p.s. One other thing: When I write a unicode string using C methods, I succeed to write it as Unicode: FILE *aOutFile = _tfopen(_T("test1.txt"), _T("w, ccs=UNICODE")); if (aOutFile != NULL) { _fputts((LPCTSTR) aStr, aOutFile); fclose(aOutFile); } But when I try to do the same thing using CFile MFC's class, it does not written in unicode: CString aStr; mEdit.GetWindowText(aStr); CStdioFile aFile; CString aFileName(_T("test1.txt")); BOOL aRetVal = aFile.Open(aFileName, CFile::modeCreate | CFile::modeWrite); if (aRetVal) { aFile.WriteString(aStr); aFile.Close(); } Can someone please explain ? thanks, Yoav.
From: Giovanni Dicanio on 11 Jan 2010 04:56 "Yoavo" <yoav(a)cimatron.co.il> ha scritto nel messaggio news:OWBxSCqkKHA.6096(a)TK2MSFTNGP02.phx.gbl... > I am trying to write a Unicode string using the method > WritePrivateProfileString, but it writes the string as ascii only. > How do I change the method's behavior to work Unicode? This may help: http://blogs.msdn.com/michkap/archive/2006/09/15/754992.aspx > p.s. > One other thing: > When I write a unicode string using C methods, I succeed to write it as > Unicode: > FILE *aOutFile = _tfopen(_T("test1.txt"), _T("w, ccs=UNICODE")); > if (aOutFile != NULL) > { > _fputts((LPCTSTR) aStr, aOutFile); > fclose(aOutFile); > } > > But when I try to do the same thing using CFile MFC's class, it does not > written in unicode: I found CStdioFile MFC class not good for Unicode text. You may find a better class on CodeProject: http://www.codeproject.com/KB/files/stdiofileex.aspx Giovanni
|
Pages: 1 Prev: Please use wxWidgets Next: How to get crash dump when a unhandled CException is thrown bya MFC app |