web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Suggested answer
    MahGah Profile Picture
    15,529 on at

    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;
  • howeidat Profile Picture
    35 on at

    it works. thank you

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans