Announcements
No record found.
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
Hi Anand,
Probably the blog from Munib can help you here: dynamicsnavax.blogspot.com/.../print-report-as-byte-array-via-x-in.html
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);
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.
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);
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.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 544 Most Valuable Professional
André Arnaud de Cal... 347 Super User 2026 Season 2
CU-1234529-002 197