Encode/decodebas64 accuracy

Hi
I’m experimenting with encodebase&decodebas64
Even though it can convert non standard latin characters I’m having problems with the subscripts/upperscrips characters.
I’m afraid they are converted into standard letters.

Can ayone confirm or tell me if I’m doing something wrong.
Here is my project
https://www.dropbox.com/s/8fe8mjvsyhhe1e2/PQConverter.xojo_binary_project?dl=0

Thanks

Encode e decode base 64 transform a byte sequence in a string limited to an alphabet composed by 64 chars and then again in the original byte sequence.
That’s all.

[quote=204209:@Horacio Vilches]Here is my project
https://www.dropbox.com/s/8fe8mjvsyhhe1e2/PQConverter.xojo_binary_project?dl=0 [/quote]

Where are in the project the characters that do not behave ?

[quote=204209:@Horacio Vilches]Hi
I’m experimenting with encodebase&decodebas64
Even though it can convert non standard latin characters I’m having problems with the subscripts/upperscrips characters.
I’m afraid they are converted into standard letters.

Can ayone confirm or tell me if I’m doing something wrong.
Here is my project
https://www.dropbox.com/s/8fe8mjvsyhhe1e2/PQConverter.xojo_binary_project?dl=0

Thanks[/quote]

Have you tried with an online encodebase/decodebas64 web site (https://www.base64encode.org/), to see if you get the same result ?

More importantly, are you defining the encoding of your string after deciding it?

I could not quite understand how the program was supposed to work, and results looked unusable, so I just tried that:

With this, I do get exactly the same upon entry and back for non styled text :

Function EncodeEncodetext() As Boolean Tarea2.Text = EncodeBase64(Tarea1.Text) return true End Function

Function DecodeSUBmenu() As Boolean Tarea1.Text = Decodebase64(Tarea2.Text, Encodings.UTF8) return true End Function

No need to split lines. EncodeBsae64 / DecodeBase64 will take care of all the content, including returns.

That works fine for non styled text, which does include some superscript numbers and letters (ª, ², ³, ¹).

However, for all other characters, subscript and superscript are styles.

Then it becomes necessary to encode/decode styled Text :

Tarea2.Text = EncodeBase64(Tarea1.StyledText.RTFData) return true

Tarea1.StyledText.RTFData = Decodebase64(Tarea2.Text, Encodings.UTF8) return true

Then I was able to prepare elaborate text composition in Word, with fonts, text size, colors, and paste it into the top TextArea, encode that, and decode it. But indeed, unfortunately, subscript and superscript get lost in translation. It seems as though the RTF parser does not recognizes subscript and superscript.

But that is not so surprising. StyleRun does not address that particular style. See http://documentation.xojo.com/index.php/StyleRun

Subscript can be simulated with half the font size or so. For superscript, I see no way around. Sorry.

In conclusion, the issue is not due to Encode/DecodeBase64, but to the limitations of TextArea styled text.

I agree with Greg or Michel, as Base64 is capable of encoding/decoding RAW data. It doesn’t discriminate. If it’s text information, it’s up to you to make sure the encoding is set properly after transmission. If you’re running into issues, that’s either the case… or it’s a limitation of the control your using (as what Michel suggested).

I would recommend using the new framework for this, as it forces you to deal with these kinds of encoding issues.

thanks Michel you always go an extra mile with yr answers ! really appreciated

You’re welcome.