Base64 decoding by hand

Hi for a project which downloads base64 encoded datafiles (later on zipped as a bonus problem) ive been using an extension for decoding whichs works fine. But for some reasons i consider compiling the app for ios.

So the extension is no more an option as i cannot find ios extensions.

Now ive done the base64 decoding by hand for which i need to convert bytes to chars and concentenate them. For most characters this works fine but i need all from chr$(0) to chr$(255) which does not work even if i have a full conversion table.

Most of the converted text reads fine except crlf and utf-8 characters ...

So here is the question:
Is there a way or shortcut to convert a byte to a char as ancient BASIC does?

Thanx in advance

Use JavaScript to convert to base64. Maybe this will solve the problem.

These draggable procedures are from @Italo:
xor_checksum.aia (4.0 KB)
asc
chr
The checksum code is mine.

1 Like
  1. Are you sure you can "compile" an app for iOS ? As far as I am aware this is not yet possible, unless you are in the test team.

  2. You are correct, it is not possible to run extensions in iOS.

  3. See this guide for how to use javascript to encode/decode base64 (3rd example)

1 Like

wow i am overwhelmed by the reactions.
Thanx to everybody.

First i will try the draggable procedures by ABG as they are most convenient. The javascript solution is also interesting i will check it out if the other solution does not work and keep it in mind for further problems.

If i get it to work, maybe somebody is interested on the base64 decoding for the same reasons as it solves the padding problem. Even if not very elegant..

Ive read about the ios testing team but there were no problem to upload the project to https://iosbuildservertest.appinventor.mit.edu. Accoording to documention i have to to some steps before compiling for ios - apple account , apple dev account, buying an iphone :- ) etc. . If needed i will apply for the testing team. If impossible i will see...
And then there is also the zip-problem under ios which must be solved in the first place.

After further investigation i cannot mark this issue as solved.
The ABG solution does not work as it does not handle cr lf correctly and utf-8 also not.

The TIMAI2 Javascript-atob-solution works a little better, cr lf are correctly restored, but for reasons i dont understand, german UTF-8 characters arent in AI2 displayed correctly.
It seems the webviewer tears the utf-8 bytes apart.

should be: ä ö ü ß
got: ä ö ü ß

Maybe its getting better if i use javascript just for character coding and let my blocks do the rest.

Regarding the crlf problem, be aware that AI2 Labels and/or Textboxes break crlf sequences passing through their .Text values. So just use variables to hold your text if you want to keep it safe.

If you can find a JSON version of the HTML utf8 code tables you need, there is a way to use that mapping to convert a bytes list to utf8 text in blocks.

Is it worth it to you?

Oh sorry i missed your answer until now.

For the moment ive switched back to the base64 extension to do the conversion because the problem was too time consuming and the ios version and the developement process is needing also more investigation...

But this problem will arise again.
I wonder if its possible to put the javascript into a complete html-page with the utf8 coding marked as meta-tag or so and get the result from webviewer...

Regarding your last comment with Json/HTML-code-table. Couldnt find any but:

Json is using utf8 by spec.
Were using csv for easy import of sheets of an excel workbook which ist edited by some guy. And ive written a python-script which is converting the excel-file to one csv for every sheet which is then transferd to the app and imported.

Maybe we should switch to json... if i so can get rid of the problem...
Must think about...

According to
https://www.google.com/search?q=export+excel+sheet+in+utf8+csv

Excel has the capability to export sheets as utf8 csv format, as long as you ask for it in Excel.

Maybe you need to prevail upon the 'some 'guy' or the export script to use that capability?

AI2 has list blocks to load csv files.

AI2 has list blocks to load csv files.

Yes, I use them. and as i do the base64 decoding by the extension everything is working fine. Its just about the option to do a port to ios.

Excel has the capability to export sheets as utf8 csv format, as long as you ask for it in Excel.

yes it has. But the python script is doing much more conversions grabbing cells together and loops over a (hopefully) growing number of sheets. I know all of this is also possible in excel but since there only a office 366 available i've switched to Libreoffice which also has python capabilites which are somewhat nasty to set up.
So its ends with a standalone pythonscript using pandas which works fine.