- Strings are not ASCII, they are 16 bit Unicode.
- I concur, there is a problem. The 1000 character string gets truncated around 700. Adding the +""+ makes no difference.
- Ticket #1590494 created.
- Use
Fh = StringConcatenate(begin_head, Fh); // <ABCDEFGHIJKLMNOPQRSTUVWXYZabcd...567 97 234567 98 234567 99:END>
#property strict void OnStart(){ { string Fh = "12345"; string begin_head = "ABCD"; Fh = begin_head + Fh; PrintFormat("<%s>", Fh); // <ABCD12345> } { string Fh = "BEG:"; for(int i=1; i < 100; ++i) Fh = Fh + StringFormat(" 234567 %2i", i); Fh = Fh + ":END"; PrintFormat("<%s...%s>", StringSubstr(Fh,0, 30), StringSubstr(Fh,StringLen(Fh) - 30) ); // <BEG: 234567 1 234567 2 23456...567 97 234567 98 234567 99:END> string begin_head = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; Fh = begin_head + Fh; PrintFormat("<%s...%s>", StringSubstr(Fh,0, 30), StringSubstr(Fh,StringLen(Fh) - 30) ); // <ABCDEFGHIJKLMNOPQRSTUVWXYZabcd... 234567 60 234567 61 234567 62> // String trimmed } { string Fh = "BEG:"; for(int i=1; i < 100; ++i) Fh = Fh + StringFormat(" 234567 %2i", i); Fh = Fh + ":END"; PrintFormat("<%s...%s>", StringSubstr(Fh,0, 30), StringSubstr(Fh,StringLen(Fh) - 30) ); // <BEG: 234567 1 234567 2 23456...567 97 234567 98 234567 99:END> string begin_head = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; Fh = begin_head + "" + Fh; PrintFormat("<%s...%s>", StringSubstr(Fh,0, 30), StringSubstr(Fh,StringLen(Fh) - 30) ); // <abcdefghijklmnopqrstuvwxyzABCD... 234567 60 234567 61 234567 62> // String trimmed } }
That bug with strings is there since build 970. I reported it @2016.06.08 11:02, #1488604
Problem description
... when concatenating long strings with the + (plus) operator the resulting string is not properly ended, and a few (cca 50) invalid buffer characters are appended.
Marki: Or are they at least mentioned in some changelog when they are fixed?
|
Previously reported 2016.06.08 11:02, #1488604
I reported 2016.10.19 15:39, #1590494
Support Team
2016.10.20 07:52
Thank you for your message. Fixed. Please wait for updates.
|
Previously reported 2016.06.08 11:02, #1488604
I reported 2016.10.19 15:39, #1590494
Support Team
2016.10.20 07:52
Thank you for your message. Fixed. Please wait for updates.
|
Where do you get that idea?
So finally. We do not expect to see any developments to come out of MT4 ever again - MQL5.community traders' Forum just has peoples opinion, nothing from Metaquotes.
And even if MT4 is not going to have any new developments, doesn't mean it won't have bug fixes.
Where do you get that idea?
So finally. We do not expect to see any developments to come out of MT4 ever again - MQL5.community traders' Forum just has peoples opinion, nothing from Metaquotes.
And even if MT4 is not going to have any new developments, doesn't mean it won't have bug fixes.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Yesterday I encountered weird string corruption, which I narrowed down to the following code:
Fh=begin_head + Fh;
Fh was more than 1000 ascii chars long, begin_head was maybe 50 chars. After this code, the resulting string was ok, but on the end contained appended part of the original string.
After changing the code to:
Fh=begin_head + "" + Fh;
the result was ok without any corruption. I had the code in 5 places in my EA (with different Fh content, same begin_head content) and all behave incorrectly.
Is the any difference how MT4 interprets those 2 string concatenations? Why adding empty string helped to prevent the corruption and why it happened in the first place? Is this some known issue?