Reading .txt file gives strange characters. Any ideas?

EdFuk
54
EdFuk  

***UPDATE - SOLVED


I should have done some more digging. I had to specify FILE_ANSI as a file open paramter.

described here......

error when reading file.txt!! why print a txt in Japanese?



Hi everyone,


I'm trying to read some numbers from a .txt file which is opened in the OnTester() function. The file appears to be opened correctly but when the variables are read they display strange characters instead of the number. The code, input file and result is shown below:


Any ideas would be appreciated. Thanks

E


   ResetLastError();
   int inputFileHandle = INVALID_HANDLE;
//string inputFileName = "TEST DATA\\DrawDown Test Data.txt";
   string inputFileName = "TEST DATA\\Test.txt";
   inputFileHandle = FileOpen(inputFileName, FILE_READ|FILE_TXT);

   if(inputFileHandle!=INVALID_HANDLE)
     {
      Print("FileOpen OK");

      // READ DATA INTO ARRAY
      int count = 0;
      double testDataBalance[];
      while(!FileIsEnding(inputFileHandle))
        {
         count++;
         // RESIZE ARRAY
         ArrayResize(testDataBalance,count);
         //READ VALUE
         string str = FileReadString(inputFileHandle);
         testDataBalance[count - 1]= StringToDouble(str);
        }
      FileClose(inputFileHandle);
      double valStart = testDataBalance[0];
      double valEnd = testDataBalance[count - 1];
     }


error when reading file.txt!! why print a txt in Japanese?
error when reading file.txt!! why print a txt in Japanese?
  • 2019.05.02
  • www.mql5.com
why print a txt in Japanese...
William Roeder
25075
William Roeder  

I only use the Editor for compiling/debugging. I use Notepad2 with code folding.

Notepad can only display ANSI files. NP2 can display and convert to and from Unicode.

Consider replacing your Notepad

EdFuk
54
EdFuk  
William Roeder:

I only use the Editor for compiling/debugging. I use Notepad2 with code folding.

Notepad can only display ANSI files. NP2 can display and convert to and from Unicode.

Consider replacing your Notepad

Hi William,


I have just downloaded Notepad++