# EncodeBase64/DecodeBase64; Web

**URL:** <https://forum.xojo.com/t/encodebase64-decodebase64-web/47147>\
**Category:** Windows\
**Created:** [January 28, 2019, 9:17am UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147 "2019-01-28T09:17:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans-Norbert\_Gratzal](https://forum.xojo.com/user_avatar/forum.xojo.com/hans-norbert_gratzal/32/2143_2.png) [@Hans-Norbert\_Gratzal](https://forum.xojo.com/u/Hans-Norbert_Gratzal)\
**Post date:** [January 28, 2019, 9:17am UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/1 "2019-01-28T09:17:04Z")

</div>

Hello!

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/](https://www.base64encode.org/) which gave me “5A==”.

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

Solution:  
[https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings/30106551](http://example.com)

`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!

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [January 28, 2019, 11:57am UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/2 "2019-01-28T11:57:34Z")

</div>

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:

> **[HTML Charset](https://www.w3schools.com/html/html_charset.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

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:  
[http://documentation.xojo.com/api/text/encoding\_text/decodeurlcomponent.html](http://documentation.xojo.com/api/text/encoding_text/decodeurlcomponent.html)  
and  
[http://documentation.xojo.com/api/text/encoding\_text/encodeurlcomponent.html](http://documentation.xojo.com/api/text/encoding_text/encodeurlcomponent.html)

---

<div class="post-metadata">

**Author:** ![Hans-Norbert\_Gratzal](https://forum.xojo.com/user_avatar/forum.xojo.com/hans-norbert_gratzal/32/2143_2.png) [@Hans-Norbert\_Gratzal](https://forum.xojo.com/u/Hans-Norbert_Gratzal)\
**Post date:** [January 31, 2019, 2:23pm UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/3 "2019-01-31T14:23:28Z")

</div>

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;-)

---

<div class="post-metadata">

**Author:** ![Hans-Norbert\_Gratzal](https://forum.xojo.com/user_avatar/forum.xojo.com/hans-norbert_gratzal/32/2143_2.png) [@Hans-Norbert\_Gratzal](https://forum.xojo.com/u/Hans-Norbert_Gratzal)\
**Post date:** [February 5, 2019, 12:34pm UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/4 "2019-02-05T12:34:57Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [February 5, 2019, 12:47pm UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/5 "2019-02-05T12:47:31Z")

</div>

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 🙂

![](https://www.dropbox.com/s/i1mvi3joo2y4hmu/Xojo%20Forums%20Answered.gif?raw=1)

---

<div class="post-metadata">

**Author:** ![Hans-Norbert\_Gratzal](https://forum.xojo.com/user_avatar/forum.xojo.com/hans-norbert_gratzal/32/2143_2.png) [@Hans-Norbert\_Gratzal](https://forum.xojo.com/u/Hans-Norbert_Gratzal)\
**Post date:** [February 5, 2019, 1:17pm UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/6 "2019-02-05T13:17:09Z")

</div>

Thanks a lot for the info!

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

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [February 5, 2019, 1:48pm UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/7 "2019-02-05T13:48:36Z")

</div>

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 🙂 No biggie

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:32pm UTC](https://forum.xojo.com/t/encodebase64-decodebase64-web/47147/8 "2020-10-29T19:32:24Z")

</div>


