|
|
Classification: |
C++ |
Category: |
Arrays & Descriptors |
Created: |
09/21/2000 |
Modified: |
01/31/2002 |
Number: |
FAQ-0676 |
Platform: |
Not Applicable |
|
Question: My test app opens a simple text file (created in Notepad) and reads it. The app runs fine without error but then it results in an empty string. What is the problem?
Answer: Here is the test app:
RFile file; RFs aFs;
(after the usual Connect, SessionPath and error checking …)
TInt err1 = file.Open(aFs,_L("file.txt"),EFileRead);
if (err1==KErrNotFound) // file does not exist iEikonEnv->InfoMsg(_L("File not found!")); else { // ok lets read file! TBuf<256> text; TFileText fileText; fileText.Set(file); TInt err2 = fileText.Read(text); if( err2 == KErrNone ) { iEikonEnv->InfoMsg(text); This is where "empty string" is displayed } else iEikonEnv->InfoMsg(_L("Not working!")); } file.Close(); aFs.Close();
Symbian OS v6 is now in Unicode; the TFileText class can only read Unicode text. It seems it cannot handle UTF8. If you use the "Save as unicode" option in Notepad to save the file, it should work.
|
|
|