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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

convert string to Byte in D365 Ax

(0) ShareShare
ReportReport
Posted on by

Hi All,

I have a requirement to convert string to byte. 

Do you know if there are any standard methods already available or code to achieve this.

Thanks,

Anand

  • André Arnaud de Calavon Profile Picture
    307,808 Super User 2026 Season 2 on at

    Hi Anand,

    Probably the blog from Munib can help you here: dynamicsnavax.blogspot.com/.../print-report-as-byte-array-via-x-in.html

  • Verified answer
    Martin Dráb Profile Picture
    241,467 Most Valuable Professional on at

    You mean a byte array and not a single byte, right?

    An easy way is using GetBytes() method of the Encoding class. For example:

    str s = "abcd";
    System.Text.Encoding encoding = System.Text.Encoding::UTF8;
    System.Byte[] array = encoding.GetBytes(s);

  • Suggested answer
    Community Member Profile Picture
    on at

    Thanks Andre and Martin for your reply.

    Yes, I could achieve using a code similar to this. Since I needed to convert strings of Japanese language, I used below code:

    str s = "abcd";

    System.Text.Encoding encoding = System.Text.Encoding::GetEncoding(932);

    System.Byte[] array = encoding.GetBytes(s);

    and it was returning the byte array.

  • HenryXie Profile Picture
    Microsoft Employee on at

    hi Anand, if you want to get the Byte array.

           str                                   strSrc = "dynamics"

           System.Byte[]                 byte;

           System.Text.Encoding    encoding = System.Text.Encoding::get_UTF8();

           byte        =  encoding.GetBytes(strSrc);

  • Martin Dráb Profile Picture
    241,467 Most Valuable Professional on at

    Anand, can you please mark the verified answer(s) (by using Did this answer your question? > Yes)?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 347 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 197

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans