I normally have success decoding quoted-printable using the sub below. I have tried to display Last Week's Most Popular Topics in a WebView, which I have done in previous weeks without a problem. This time I cannot display the decoded html properly. I am attaching the unprocessed rawmail for this weeks topic. I expect that something has changed in the way it has been encoded. I cannot decode it correctly, in the way I have done previously, and hope someone can tell my why, and also how I might change my method of decoding quoted-printable. Any help greatly appreciated.
Best regards
Best regards
B4X:
Sub DecodeQuotePrintable(q As String) As String
Dim m As Matcher
m = Regex.Matcher("=\?([^?]*)\?Q\?(.*)\?=$", q)
If m.Find Then
Dim charset As String
Dim data As String
charset = m.Group(1)
data = m.Group(2)
Dim bytes As List
bytes.Initialize
Dim i As Int
Do While i < data.Length
Dim c As String
c = data.CharAt(i)
If c = "_" Then
bytes.AddAll(" ".GetBytes(charset))
Else If c = "=" Then
Dim hex As String
hex = data.CharAt(i + 1) & data.CharAt(i + 2)
i = i + 2
bytes.Add(Bit.ParseInt(hex, 16))
Else
bytes.AddAll(c.GetBytes(charset))
End If
i = i + 1
Loop
Dim b(bytes.Size) As Byte
For i = 0 To bytes.Size - 1
b(i) = bytes.Get(i)
Next
Return BytesToString(b, 0, b.Length, charset)
Else
Return q
End If
End Sub