Hi there
In my b4a I use this sub to convert a map to a querystring that I eventually pass to HTTP to execute a PHP request from my MySQL db.
Is there a method to encode strings in banano, for example, Im using stringutils for this..
Thanks in advance...
In my b4a I use this sub to convert a map to a querystring that I eventually pass to HTTP to execute a PHP request from my MySQL db.
Is there a method to encode strings in banano, for example, Im using stringutils for this..
B4X:
'convert a map to a querystring
Sub Map2QueryString(sm As Map) As String
' convert a map to a querystring string
Dim SU As StringUtils
Dim iCnt As Int
Dim iTot As Int
Dim sb As StringBuilder
Dim mValue As String
sb.Initialize
' get size of map
iTot = sm.Size - 1
iCnt = 0
For Each mKey As String In sm.Keys
mValue = sm.Getdefault(mKey,"")
mValue = mValue.trim
mValue = SU.EncodeUrl(mValue, "UTF8")
mKey = mKey.Trim
If mKey.EndsWith("=") = False Then mKey = mKey & "="
sb.Append(mKey).Append(mValue)
If iCnt < iTot Then sb.Append("&")
iCnt = iCnt + 1
Next
Return sb.ToString
End Sub
Thanks in advance...