The following is a method rewritten based on a set of methods in apache-jcommons. It can be used to solve quoted-printable encoded strings, similar
= B9 = E3 = B6 = AB = D2 = BB = BA = DA = CD = F8 = B0 = C9 = C9 = EE = D2 = B9 = C6 = F0 = BB = F0 = B4 =
= F3 = BB = F0 4 = C8 = CB = D4 = E1 = C9 = ED = BB = F0 = BA = A3
This encoding is usually used in emails. This encoding is also used in the MHT files stored by IE. It is difficult to find java Implementation on the Internet, so it is provided here.
Public final String qpDecoding (String str)
{
If (str = null)
{
Return "";
}
Try
{
Str = str. replaceAll ("= ","");
Byte [] bytes = str. getBytes ("US-ASCII ");
For (int I = 0; I <bytes. length; I ++)
{
Byte B = bytes [I];
If (B! = 95)
{
Bytes [I] = B;
}
Else
{
Bytes [I] = 32;
}
}
If (bytes = null)
{
Return "";
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream ();
For (int I = 0; I <bytes. length; I ++)
{
Int B = bytes [I];
If (B =)
{
Try
{
Int u = Character. digit (char) bytes [++ I], 16 );
Int l = Character. digit (char) bytes [++ I], 16 );
If (u =-1 | l =-1)
{
Continue;
}
Buffer. write (char) (u <4) + l ));
}
Catch (ArrayIndexOutOfBoundsException e)
{
E. printStackTrace ();
}
}
Else
{
Buffer. write (B );
}
}
Return new String (buffer. toByteArray (), "GBK ");
}
Catch (Exception e)
{
E. printStackTrace ();
Return "";
}
}