يعانى البعض من قراءة ملف نصى يحتوى على نصوص يونيكود “Unicode” فى تطبيقات C/C++
CTextFile تغليف لكلاس CStdioFile لدعم قراءة نصوص تحتوى على يونيكود.

#include "TextFile.h" #include <atlstr.h> #define szAppTitle L"Unicode Application" int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CString cmdline(lpCmdLine); if(cmdline.Trim().IsEmpty()) { MessageBox(NULL, L"Usage: TestTextFile.exe \n", szAppTitle, MB_ICONASTERISK); return -1; } CString szBuffer; try { // Open text file with utf8 CTextFile textFile(CTextFile::UTF8); if(textFile.Open(cmdline)) { CString szLine; while(textFile.ReadString(szLine)) { szBuffer.AppendFormat( L"%s\n", szLine); } textFile.Close(); } } catch(CFileException *ex) { ex->Delete(); return -1; } MessageBox(NULL, szBuffer, szAppTitle, 0); return 0; }