Android Question Smart strings from Database ?

FrankDev

Active Member
Licensed User
Longtime User
Hello,

possible to read the 'smart string' from a database ?

for example:

BBCodeView1.Text = $ & Variable & $

instead of:
BBCodeView1.Text = $"[Alignment=Center]Bitte ${CreateNamedLink("Anmelden","https://yourniceurl","#2D8879")}/${CreateNamedLink("Registrieren","https://yourniceurl","#2D8879")} um ein kommentar zu schreiben[/Alignment]"$

or is that only possible in the souce because it is also compiled

I am interested in the integration of functions (here e.g. CreateNamedLink)

B4X:
Public Sub CreateNamedLink(name As String,url As String,color As String) As String
    Return "[b][url=""" & url & """][color=" & color & "]" & name & "[/color][/url][/b]"
End Sub
Example from 'Alexander Stolte'

regards Frank
 

KMatle

Expert
Licensed User
Longtime User
Try to Base64 encode the bytes of the string (StringUtils Library) like

B4X:
Dim su As StringUtils
Dim MySmartString As String =  $"[Alignment=Center]Bitte ${CreateNamedLink("Anmelden","[URL='https://yourniceurl/']https://yourniceurl[/URL]","#2D8879")}/${CreateNamedLink("Registrieren","[URL='https://yourniceurl/']https://yourniceurl[/URL]","#2D8879")} um ein kommentar zu schreiben[/Alignment]"$ 
Dim MyBase64String as string = su.EncodeBase64(MySmartString.GetBytes("UTF8"))

store it to the db, convert it back and "load" it like you've shown.

What it does: It get's the bytes from the Smart String as Bytes ("as it is") and converts it to Base64 (which is just a simple string which is storable without problems as it juses jzst some basic characters and no "special chars" like " or ').
 
Upvote 0
Top