How do you convert a byte array to a string? I need to get the raw content, e.g. "96=A8=FC-=A8=FE", but when I use say Encoding.UTF8.GetString(bytes), it returns "96��-��". Thanks!
I think you misunderstand the content of strings. The closest you'll get to "raw content" is to use Encoding.Unicode - .NET uses UTF-16 internally, so converting to UTF-16 is effectively just a case of copying the contents of memory from the string to the byte array.
Now, to come back to your problem, what data do you have, what is it meant to represent and why? Textual data is characters. Binary data is numbers, basically. You have to have a mapping between the two, and that's the encoding.
I have an article on Unicode which may help you, but I strongly suspect you'll need to take a step back before you make any progress.
If you're trying to convert a byte array into a string representation of those bytes as hex, you can just use BitConverter.ToString(byte[]) but I wouldn't describe that as a "raw" conversion.
EDIT: Okay, now that we have the context, it's much easier to answer. What you're looking at is quoted printable encoding. The email should specify the encoding of the quoted printable, so when you decode the QP encoding, that's what you should use. If you're not currently storing the content encoding of the original email, you should start doing so right now...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With