-
August 30th, 2011, 04:26 AM
#1
Is it possible to read text file of type ANSI and unicode using CStdioFile as shown a
Actually I converted my VC .net project from Use Multi-Byte Character Set to Use Unicode Character Set (i.e. Unicode support). Then lot of build errors fixed.
Before in my project, I’m reading the ANSI text file as below
CStdioFile l_oStdioFile;
CString l_strValue = _T("");
TCHAR l_chBuff[1024*10];
CFileException l_oFileEx;
CString m_strFileName = _T("C:\\Documents and Settings\\PHari\\Desktop\\ASAS.txt");
BOOL l_bResult = false;
try
{
l_bResult = l_oStdioFile.Open(m_strFileName,CFile::modeRead,&l_oFileEx);
int count = l_oStdioFile.GetLength();
if(!l_bResult)
return;
UINT l_nBytesRead = l_oStdioFile.Read(l_chBuff,1024*10);
l_oStdioFile.Close();
int l_nIndex = 0;
for(int l_nCount = 0; l_nCount < (int)l_nBytesRead; l_nCount++)
{
l_strValue += l_chBuff[l_nCount];
}
}
catch(CFileException oFileEx)
{
}
Once I changed my project to Unicode support. With the above code, I’m trying to read the Unicode text file, it is working fine.
But if I try to read the ANSI text file, it is not reading properly. This problem is coming Once I built my project with Unicode support.
Is it possible to read text file of type ANSI and unicode using CStdioFile as shown above? Or where I’m doing wrong?
My requirement is I need to read the text file of type ANSI and Unicode with above code.
Any help is appreciated.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|