top of page
Suche
  • AutorenbildPedro Rodriguez

Convert from Hexadecimal to String with X++


Here below a very useful code that could help you. In my case I needed to transfer a payload from an external system to Dynamics 365 Finance/SCM. This payload was a JSON message that I needed to transform to Hexadecimal string before sending it to Dynamics 365, through a Custom Service, to avoid possible character/format problems when reading the JSON at the other side.


To generate a hexadecimal string that you can use to try this X++ method you can use online services like:


https://string-functions.com/string-hex.aspx


Below the code:


//Convert the given string from Hexadecimal format to String

private str hex2String(Str _hex)

{

str result;

str hex;

int value;

int i;


for (i=0; i<strLen(_hex)/2; i++)

{

hex = subStr(_hex, i*2 +1 , 2);

value = hex2Int(hex);

result += num2Char(value);

}


return result;

}


This code worked well with German characters, so the use of extra .NET libraries could be avoided.


92 Ansichten0 Kommentare

Aktuelle Beiträge

Alle ansehen

Comments


bottom of page