using System . Collections;
using System . Globalization;
public string QuotedPrintableEncode( string AText) // QP
{
string Result = "" ;
byte [] vBuffer = Encoding . Default . GetBytes(AText);
foreach ( byte vByte in vBuffer)
//
if ((vByte >= 33 && vByte <= 60 ) || (vByte >= 62 && vByte <= 126 ))
Result += ( char )vByte;
else Result += "=" + vByte . ToString( "X2" );
return Result;
}
public static string QuotedPrintableDecode( string ACode) //
{
ArrayList vBuffer = new ArrayList ();
for ( int i = 0 ; i < ACode . Length; i ++ )
{
if (ACode[i] == '=' )
{
i ++ ;
if (ACode[i] != '\r' )
{
byte vByte;
if ( byte . TryParse(ACode . Substring(i, 2 ),
NumberStyles . HexNumber, null , out vByte))
vBuffer . Add(vByte);
}
i ++ ;
}
else if (ACode[i] != '\n' ) vBuffer . Add(( byte )ACode[i]);
}
return Encoding . Default . GetString(( byte [])vBuffer . ToArray( typeof ( byte )));
}
private void button1_Click( object sender , EventArgs e)
{
Text = QuotedPrintableDecode(QuotedPrintableEncode( "zswang ));
}