public static string DecodeByteArrayToString(byte[] byteArray, Encoding byteEncoding)
{
if (null == byteArray)
{
////no bytes to convert
return null;
}
Decoder byteArryDecoder;
if (null == byteEncoding)
{
byteArryDecoder = Encoding.UTF7.GetDecoder();
}
else
{
byteArryDecoder = byteEncoding.GetDecoder();
}
int charCount = byteArryDecoder.GetCharCount(byteArray, 0, byteArray.Length);
char[] bodyChars = new char[charCount];
return new string(bodyChars);
}