read File ini in mt5 why retrun cinese char?

 

Hi guys i try to read a file ini , my file ini  have this name  correlazioni.ini   and is located  inside of  .....\MQL5\Files  , inside of  correlazioni.ini  i have this structure

 [primario]
symbl1=AUDUSD+
....
...
..
[correlato]
symbl1=NZDUSD+
....
...
..
[soglia_minima]
symbl1=0.4
....
...
..

i try to count  the line  and read in this mode

int _CountLinesInFile(string fileName)
{
    int linesCount = 0;
    int fileHandle = FileOpen(fileName, FILE_READ);
      // Leggi la prima riga del file
    string line = FileReadString(fileHandle);
    
    // Stampa la riga letta
    Print("Contenuto della prima riga: ", line);
    
    if (fileHandle != INVALID_HANDLE)
    {
        // Scorri il file riga per riga
        while (!FileIsEnding(fileHandle))
        {
            string line = FileReadString(fileHandle);
            linesCount++;
        }
        FileClose(fileHandle);
    }
    return linesCount;
}
i suppose fileopen  work in correct folder 
Files:
 

Set the correct format and code page when calling the FileOpen function.

open_flags

[in] combination of flags determining the operation mode for the file. The flags are defined as follows:
FILE_READ file is opened for reading
FILE_WRITE file is opened for writing
FILE_BIN binary read-write mode (no conversion from a string and to a string)
FILE_CSV file of csv type (all recorded items are converted to the strings of unicode or ansi type, and are separated by a delimiter)
FILE_TXT a simple text file (the same as csv, but the delimiter is not taken into account)
FILE_ANSI lines of ANSI type (single-byte symbols)
FILE_UNICODE lines of UNICODE type (double-byte characters)
FILE_SHARE_READ shared reading from several programs
FILE_SHARE_WRITE shared writing from several programs
FILE_COMMON location of the file in a shared folder for all client terminals \Terminal\Common\Files

codepage=CP_ACP

[in]  The value of the code page. For the most-used code pages provide appropriate constants.

Constant

Value

Description

CP_ACP

0

The current Windows ANSI code page.

CP_OEMCP

1

The current system OEM code page.

CP_MACCP

2

The current system Macintosh code page.

Note: This value is mostly used in earlier created program codes and is of no use now, since modern Macintosh computers use Unicode for encoding.

CP_THREAD_ACP

3

The Windows ANSI code page for the current thread.

CP_SYMBOL

42

Symbol code page

CP_UTF7

65000

UTF-7 code page.

CP_UTF8

65001

UTF-8 code page.

Documentation on MQL5: File Functions / FileOpen
Documentation on MQL5: File Functions / FileOpen
  • www.mql5.com
The function opens the file with the specified name and flag. Parameters file_name [in]  The name of the file can contain subfolders. If the...
 

thanks , but not  work , i use all type of codepage , but return always chines  char, i save my ini file  with notepad with utf8 i suppose i must use 65001  but not work after this i test all but have always the same effect 0_o

 
int hFileHandle = FileOpen( sFileName, FILE_READ | FILE_TXT | FILE_ANSI, (short) NULL, CP_UTF8 ); 
 
Fernando Carreiro #:
int hFileHandle = FileOpen( sFileName, FILE_READ | FILE_TXT | FILE_ANSI, (short) NULL, CP_UTF8 );

aaaaaaaaaaaaaaaaa    ok thanks  now  is much clear , i lost  this concatenation

, FILE_READ | FILE_TXT | FILE_ANSI, (short) NULL,