Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Convert Text to Hex

(0) ShareShare
ReportReport
Posted on by 35

Hello

I want to convert text to hex using AL code. Is there any function that can do so?

I am working on cloud Business Central so I can't use any Dot Net library.

example:

Text Input = Bobs Records

Hex Result = 426F6273205265636F726473

Thanks

  • howeidat Profile Picture
    howeidat 35 on at
    RE: Convert Text to Hex

    it works. thank you

  • Suggested answer
    MahGah Profile Picture
    MahGah 15,433 on at
    RE: Convert Text to Hex

    Hi

    See this post  forum.mibuso.com/.../how-to-convert-text-to-hexadecimal-in-nav-2005

    specially the following by Duikmeester

    OnRun()
    MESSAGE('0x%1',ConvertBase16('Hogan'));
    
    LOCAL ConvertBase16(theInput : Text[512]) theOutput : Text[1024]
    FOR aIndex := 1 TO STRLEN(theInput) DO BEGIN
      aInt := theInput[aIndex];
      aLeft := ROUND(aInt / 16,1,'<');
      aRight := aInt MOD 16;
      theOutput += HexValue(aLeft) + HexValue(aRight);
    END;
    
    LOCAL HexValue(theValue : Integer) : Text[1]
    CASE theValue OF
      0..9: EXIT(FORMAT(theValue));
      10:   EXIT('A');
      11:   EXIT('B');
      12:   EXIT('C');
      13:   EXIT('D');
      14:   EXIT('E');
      15:   EXIT('F');
    END;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,791 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,488 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans