public static byte[] QuotedPrintableDecodeB(byte[] data,bool includeCRLF)
{
MemoryStream strm = new MemoryStream(data);
MemoryStream dStrm = new MemoryStream();
int b = strm.ReadByte();
while(b > -1){
// Hex eg. =E4
if(b == '='){
byte[] buf = new byte[2];
strm.Read(buf,0,2);
// <CRLF> followed by =, it's splitted line
if(!(buf[0] == '\r' && buf[1] == '\n')){
try{
byte[] convertedByte = FromHex(buf);
dStrm.Write(convertedByte,0,convertedByte.Length);
}
catch{ // If worng hex value, just skip this chars
}
}
}
else{
// For text line breaks are included, for binary data they are excluded
if(includeCRLF){
dStrm.WriteByte((byte)b);
}
else{
// Skip \r\n they must be escaped
if(b != '\r' && b != '\n'){
dStrm.WriteByte((byte)b);
}
}
}
b = strm.ReadByte();
}
return dStrm.ToArray();
}