Convert Byte array to String
public enum EncodingTypes
{
ASCII,
Unicode,
UTF7,
UTF8
}
public string ByteArraytoStringarray(byte[] imgbyte, EncodingTypes encodetype)
{
System.Text.Encoding encoding = null;
switch (encodetype)
{
case EncodingTypes.ASCII:
encoding = new System.Text.ASCIIEncoding();
break;
case EncodingTypes.Unicode:
encoding = new System.Text.UnicodeEncoding();
break;
case EncodingTypes.UTF7:
encoding = new System.Text.UTF7Encoding();
break;
case EncodingTypes.UTF8:
encoding = new System.Text.UTF8Encoding();
break;
}
return encoding.GetString(imgbyte);
}
public enum EncodingTypes
{
ASCII,
Unicode,
UTF7,
UTF8
}
public string ByteArraytoStringarray(byte[] imgbyte, EncodingTypes encodetype)
{
System.Text.Encoding encoding = null;
switch (encodetype)
{
case EncodingTypes.ASCII:
encoding = new System.Text.ASCIIEncoding();
break;
case EncodingTypes.Unicode:
encoding = new System.Text.UnicodeEncoding();
break;
case EncodingTypes.UTF7:
encoding = new System.Text.UTF7Encoding();
break;
case EncodingTypes.UTF8:
encoding = new System.Text.UTF8Encoding();
break;
}
return encoding.GetString(imgbyte);
}
Comments
Post a Comment