top of page
Suche

Convert from Hexadecimal to String with X++

Autorenbild: Pedro RodriguezPedro Rodriguez

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.


 
 
 

Comments


Dipl.-Ing. Pedro Rodriguez


Tel.      : +49 159 017 98 997
E-Mail   : pedro.rodriguez@d365free.com
Adresse: Marie-Curie-Straße 10

             49076 Osnabrück

Contact
Follow me
Membership

Dipl. -Ing. Pedro Rodriguez IdNr.: DE 317316808

Insured by ALLIANZ Versicherungs-AG (Haftpflichtversicherung)

Download.jfif
Screenshot 2022-10-08 101857.png
bottom of page