convert string to hex encoding Hexidecimal

 
// insert a string and convert to HEX keycode numbers 
string HEX =  convert_String_HEX(hash);

// pass in string a4985jnjw983njksd023H03jr83Jje93
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 hex = run_hex(symbol);
   add += ""+hex;
  }
  return(add);
}

ushort run_hex(string char_value){
// how to convert a-z , A-Z , 0-9  to HEX
}


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

string concatenate = StringGetCharacter(mystring,i);

within the loop, but the values are ASCI int values and not the values of HEX, http://string-functions.com/string-hex.aspx

Best String To Hex Converter Online | String Functions
Best String To Hex Converter Online | String Functions
  • string-functions.com
> Hex to text converter Hexadecimal notation is used as a human-friendly representation of binary values in computer programming and digital electronics. Most programming languages such as Java, ASP.NET, C++, Fortran etc have built-in functions that convert to and from hex format. Read more about hexadecimal in Wikipedia Privacy Policy...
 
torytoryI 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)); // 280a
          Common 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);

}
Reason: