Unicode problem with CStdioFile in VC++
I am trying to read in a URL such as http://google.com The Url is opened fined, and as soon as I read in the first line in the while(...) loop, instead of getting some 开发者_如何转开发sensible characters representing html, I get weird Chinese characters into sCurlLine which is a CString. I think i am missing a unicode encoding/decoding part. The following is the simple code that reads a URL. The while loop reads line by line the file and the text is then updated into a text box.
Thanks for the help
void CInetSessionDlg::OnBnClickedBurl()
{
CStdioFile * fpUrlFile;
CString sCurlLine;
UpdateData(TRUE);
LPCTSTR url = m_sURL;
fpUrlFile = m_misSession.OpenURL(url);
if(fpUrlFile)
{
while(fpUrlFile->ReadString(sCurlLine))
{
m_sResult += sCurlLine;
UpdateData(FALSE);
}
}
}
Check that you are building is configured to use the correct project configuration settings. Setting found: Project Properties|General|Project Defaults|Character Set
Maybe you have the wrong set "Not Set" | "Use Unicode"
精彩评论