EncodeBase64/DecodeBase64; Web


I am creating a Base64 encoded string like this:

[code]dim S as String

S = “”
//S = S.DefineEncoding(Encodings.UTF8)
S = EncodeBase64(S)
System.DebugLog(“EncodeBase64:” + S)[/code]

As You can see, I tried with and without DefineEncoding.

The letter “” shall be converted to “5A==” to be used in browser (current Chrome or Firefox).
But it is converted to “w6Q=”; so, it is converted by JavaScript with atob(‘w6Q=’) and gets “messed” letter.

Any ideas what I am doing wrong?
As a “reference” I tried converting “” here https://www.base64encode.org/ which gave me “5A==”.

Even I found the solution writing this, I ut in in this forum for future ref…


let b64DecodeUnicode = (str) => { // Going backwards: from bytestream, to percent-encoding, to original string. return decodeURIComponent(atob(str).split('').map(function(c) { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); }).join('')); };

So, problem is at browser side!

Are-you sure you want to BASE64 the letter instead of getting its internet value (ä for example) ?

In UTF-8, is:
228 Latin small letter a with diaeresis

More information here:

Nota, in Xojo, there is something to convert this kind of stuff, but I forgot its name and failed to recover it in the docs. Sorry.

Edit: I found it; read:

Thanks a lot for the info!

It is really a browser problem concerning atob and UTF-8.

The reason I use Base64 is that with “raw” text values/umlauts , it did not work at all (ORACLE ASCII, Xojo, Firefox).

Oh, just noticed that we did a switch to ORACLE-Unicode this week; maybe give it a try without Base64 again -> I expect either the worse;-)

The overall solution is to use SQLPlugin from MonkeyBread Software which is “only” a SQLAPI++ mapping for Xojo and therefore only some less Euros!

In Xojo help should be a hint or link to MonkeyBread Software; no one likes to work with ORACLE but many have to…

If you look in the bottom right corner of the post you wish to mark as a solution you can mark the thread as solved instead of editing the title :slight_smile:

Thanks a lot for the info!

Will do it in the future even when I found the solution while writing the question.

hehe yeah that’s missing the option, doh!

A quick post to the effect of “Solution in OP” then you could mark that post as the answer. It just stops people coming in here to help when the answer is already known :slight_smile: No biggie