Sub UnMIME(s2match As String, CharSet As String) As String
Dim m As Matcher
Dim cnv As ByteConverter
Dim SupportedEncodings() As String
Dim booCharSetIsValid As Boolean
Dim c2match As String
Dim j As Int
SupportedEncodings = cnv.SupportedEncodings
booCharSetIsValid = False
For j = 0 To SupportedEncodings.Length - 1
If CharSet.ToUpperCase = SupportedEncodings(j).ToUpperCase Then
booCharSetIsValid = True
End If
Next
If booCharSetIsValid = True Then
If CharSet.Trim.ToLowerCase = "utf-8" Then
c2match = "=[0-9a-fA-F][0-9a-fA-F]=[0-9a-fA-F][0-9a-fA-F]"
Else
c2match = "=[0-9a-fA-F][0-9a-fA-F]"
s2match = s2match.Trim
s2match = s2match.Replace(" ","=20")
If s2match.EndsWith("=") = True Then
s2match = s2match.SubString2(0,s2match.Length-1)
End If
End If
m = Regex.Matcher(c2match,s2match)
Do While m.Find = True
s2match = s2match.Replace(m.Group(0), cnv.StringFromBytes(cnv.HexToBytes(m.Group(0).Replace("=","")), CharSet))
m = Regex.Matcher(c2match,s2match)
Loop
End If
Return s2match
End Sub