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.