CharArrayToString(buffer, 0, -1, 1200); does not copy unicoded std::wstring myString from C++ DLL into MT5 string properly
The documentation states "till terminal 0" CharArrayToString - Conversion Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The uchar buffer array contents in MT5 is shown below:
Message from DLL (len=19) in C++ reads:
std::wstring myString = L"Hello from C++ DLL!\0\0";The uchar array contents is correct for the Unicoded text with '0' as part of each UTF-16 character.
But MQL5 code
MQL5 converts the incoming uchar buffer filled by the DLL to the following receivedString: "" (length: 0).
Apparently, CharArrayToString() is not using the UTF-16 (1200) code page properly.
What is happening? How do I convert incoming Unicoded sting from C++ DLL in uchar array to a MT% string variable properly?