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

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 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
    237,795 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
    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
    237,795 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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=%2F.++6" - Nested quantifier +.