FileOpen - File Functions - MQL4 Reference
It's a text file not binary. Open it as a TXT|UNICODE
FileOpen - File Functions - MQL4 Reference
I did it this way, but it only gives the first line of the mq4:
int handle=FileOpen("test.mq4",FILE_READ|FILE_TXT|FILE_UNICODE); if(handle!=INVALID_HANDLE) { string filetext=FileReadString(handle,(int)FileSize(handle)); } FileClose(fileHandle);What did I wrong?
I did it this way, but it only gives the first line of the mq4:
What did I wrong?int handle = FileOpen("test.mq4",FILE_READ|FILE_TXT|FILE_UNICODE); if(handle != INVALID_HANDLE){ while(!FileIsEnding(handle)){ string filetext = FileReadString(handle, FileReadInteger(handle, INT_VALUE)); PrintFormat(filetext); } FileClose(handle); }
Thank you Pavel, but unfortunately it doesn't work.
It only gives the first line of the text.
Thank you Pavel, but unfortunately it doesn't work.
what are the errors in the log?
this example should work
what are the errors in the log?
this example should work
Update: my fail, sorry. The code works! Thank you Pavel!
Update: my fail, sorry. The code works! Thank you Pavel!
New problem: I tried this code on a UTF-8 text and it doesn't work (gives a gibberish result).
Since I don't know in advance that the source file is UTF-8 or UTF-16, I need a solution that works with both case.
Or
Is it possible to detect by MQL if a file is UTF-8 or UTF-16?
Have you any idea?
Another question: is it possible to cross-convert from UTF8 to UTF16 and vice versa by MQL?
change the encoding by overwriting the file
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a file called test.mq4.
I need to get its content as a string in my other mq4 program.
The test.mq4 is an UTF-16 file. If I convert it to UTF-8 (by an external text editor), I can get its content like this:
How can I get the content of the UTF-16 file as a string (ie, without using an external conversion to UTF-8)?