Given a byte array (byte) is there any quick (as in short and aesthetic) way of transforming this into a string och character array? Assume that the bytes in the array is text represented in ascii.
I’m working in c# right now, and can’t find any obvious methods to use. But I’m also interested in a general solution applicable to any modern programming language.
System.Text.ASCIIEncoding.ASCII.GetString will return a string from the given byte array.
Important note: as noted here – Strings are Unicode, so you must specify an encoding on conversion.
System.Text.ASCIIEncoding is one option, but make sure that the byte array contains only ASCII encoded characters.