torytory: I would like to insert
a string of any length ( a string with numbers and letters), and get an output of numbers
in HEX.
If you already have a string, there is nothing to do. If you have a number,
that you can output in HEX.
string convert_String_HEX(ulong n){ return StringFormat("%I64x", n); } ulong n=1024*10+10; Print(convert_String_HEX(n)); // 280aCommon Functions / PrintFormat - Reference on algorithmic/automated trading language for MetaTrader 5
Hex encoding is performed by converting data to 2 hex characters.
MQL4
StringGetChar("q", 0) returns 113 (ASCII code) instead of 81 (key code).
With the URL shared , "q" = 71 and "Q" = 51
ushort hex(ushort value ){ return( StringFormat("%x", value) ); } string convert_String_HEX(string convert_this){ int length = StringLen(convert_this); string add; string symbol; for(int i = 0 ; i< length; i++){ symbol= StringSubstr(convert_this,i,1); ushort b = StringGetCharacter(symbol,0); Print("stringGetCh(q): " + b ); add +=""+ hex(b); } return(add); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I would like to insert a string of any length ( a string with numbers and letters), and get an output of numbers in HEX.
I have tried this
within the loop, but the values are ASCI int values and not the values of HEX, http://string-functions.com/string-hex.aspx