Android Question HTML Decoding/Encoding question

William Hunter

Active Member
Licensed User
Longtime User
I am working at displaying eMail messages in a WebView. I have found one particular Content Type that will not display. I have attached two text files. The file BodyLibraryMP has been processed directly from the mail server by Mailparser in the normal manner. The file BodyLibraryTB was first downloaded into Thunderbird, then forwarded to me for processing by Mailparser again. They are both the same message.

BodyLibraryMP will not display in a WebView, while BodyLibraryTB displays very well. It seems that Thunderbird does some Decoding/Encoding in the process of forwarding this message. I would like to duplicate this process within my app if possible. Can someone explain to me how this might be done? Also, what is the content type of BodyLibraryTB? Any help greatly appreciated.


Best regards
 

Attachments

  • BodyLibraryMP.txt
    27.8 KB · Views: 214
  • BodyLibraryTB.txt
    7.2 KB · Views: 184

sorex

Expert
Licensed User
Longtime User
Why don't you follow some html tutorial first so that you can figure out what goes wrong by looking at the content/source?

we are not here to solve each mail body that doesn't display right.

most of both displays fine in firefox so I don't see any problems on these.
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
The fact that each of these files display well in a commercial viewer such as Firefox is irrelevant to my question. I am working solely with the B4A MailParser and WebView. I have been doing a lot of reading re HTML, and find things to be somewhat confusing. According to HTML standards, each HTML document requires a document type declaration. I can find no reference to meta http-equiv="content-type" content="text/html; charset=windows-1252, as a document type in any of the documentation I have read. Hence the reason for my question. I am simply asking if there is a way to decode the errant file (message) into a format that can be displayed using the tools we have at hand in B4A. Who knows, warwound may see this as child's play, and has the solution in his toolbox.

Sorex, some of us have a lot to learn. So, be patient with us. You have been very helpful in the past, and I would hope to have your assistance in the future.

Best regards
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I tried it and it displays the same thing in a webview as on firefox.
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
I tried it and it displays the same thing in a webview as on firefox.
Thank you sorex. When you loaded BodyLibraryMP into a WebView, did you use the txt or html extension? I have declared MsgBody as a String, and that string would have no extension. I'm wondering if I have to add the html extension prior to loading into the WebView.

I haven't done this, however other messages not in this content type display OK. Can you post the code you used to display the message in a WebView - just the bit WebViewBody.LoadHtml(MsgBody).

Best regards

Edit: I know that the contents of these text files can be copied into a script editor, then saved as an HTML file, to then to be loaded and displayed in Firefox. I do this myself.

Edit2: I will start by saving a fresh non-viewable file from the Dalvik Debug Monitor tomorrow. I need to ensure that I haven't mixed up a few files over a long series of testing. Sorry for any confusion, but this has been taking me in circles. I need a fresh start.
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
I just used this

B4X:
WebView1.Width=100%x
WebView1.Height=100%y
WebView1.Left=0
WebView1.Top=0
Dim html As  String=File.ReadString(File.DirAssets,"BodyLibraryMP.htm")
WebView1.LoadHtml(html)
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
Thank you sorex. At least I now know I'm doing that right. I was in error yesterday, in that I posted a file other than that intended. I made the mistake of renaming good HTML for bad. My bad! I had reached the point where I just should have shut things down for the day.

I am running my code in the emulator, and doing a File.WriteString of the parsed message to storage for later retrieval from the Android Device Manager. I was doing this for messages that would not display, as well as a few that did display OK. Most errant messages were simply truncated so the top with the content type was intact. I was then making comparisons between good and bad to see if the problem rested with content type or encoding, or a combination of both. For those messages that came through Mailparser as 0 Byte files I was using the Top command to see if the Top 30 lines would contain the content type. This wasn't very helpful.

I have made some useful observations, and learned a little in the process. I now think any work I have to do will have to be done in the Mailparser. The question I should have asked at the outset is: has anyone had success in modifying the Mailparser to handle additional content types and/or encoding? If anyone having done this would share their knowledge it would be greatly appreciated

Best regards
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…