Android Question ISO Convert problem

Ran Espensen

Member
Licensed User
Longtime User
From my E-mail app i get the subject as

Subject = "=?ISO-8859-1?B?RW1uZSDm+OXG2MU=?="

Dim arrBytes() As Byte
Dim Var As String
Dim Result As String
Var = Subject
arrBytes = Var.GetBytes("ISO-8859-1")
Result = BytesToString(arrBytes,0,arrBytes.Length, "ISO-8859-1")

'Result is still.. "=?ISO-8859-1?B?RW1uZSDm+OXG2MU=?="

What is the problem.. ??
 

b4auser1

Well-Known Member
Licensed User
Longtime User
Below my Sub to build subject string including url with description of format for e-mail subject. Based on my Sub you can create Sub to perform conversion back to plain String. Use l_sCharset As String = "ISO-8859-1" instead of "UTF8", DecodeBase64 instead of EncodeBase64 and etc.
B4X:
' http://www.sendblaster.com/en/utf8-email-subject-encoder
Private Sub Subject_EncodeBase64() As String
    Dim Const l_sCharset As String = "UTF8"
    ' The encoding must be either B or Q, these mean base 64 and quoted-printable respectively.
    ' You can read the RFC 1342 document for more information about how they work.
    Dim Const l_sEncoding As String = "B"
 
    Dim l_su As StringUtils
    Return $"=?${l_sCharset}?${l_sEncoding}?${l_su.EncodeBase64(Subject.GetBytes(l_sCharset))}?="$
End Sub
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
Thanks, but i need to decode not encode its the other way arround, need plain txt
Take a look at my text I put above the code.
Below my Sub to build subject string including url with description of format for e-mail subject. Based on my Sub you can create Sub to perform conversion back to plain String. Use l_sCharset As String = "ISO-8859-1" instead of "UTF8", DecodeBase64 instead of EncodeBase64 and etc.
 
Upvote 0
Top