I'm reading metadata from specific bytes in files but the results I get have no encoding. I would like to encode them to Encoding.Default for readability.
How do I convert either full Unicode string or at least a single char?
C# .NET 3.5
You don't encode bytes to a particular encoding - you decode them from the original encoding. You have to use the right encoding to use - you can't just pick it arbitrarily.
Do these bytes actually represent text data? If so, what encoding do the already use? This should be part of the file format.
If they're not actually encoded text, but you want a reliable text representation of arbitrary binary data, use Convert.ToBase64String.
var myString = System.Text.Encoding.Unicode.GetString(myByteArray);
Would that work?
It will be something like this:
string s = Encoding.UTF8.GetString(bytesToGetStringFrom, 0, bytesToGetStringFrom.Length);
There are "encodings" other than UTF8.