iOS Question [RESOLVED] DecodeBase64 Abnormal behavior

MarcoRome

Expert
Licensed User
Longtime User
Today is so.
I have this code:

B4X:
Sub JobDone(Job As HttpJob)

    If Job.Success Then
        Dim res As String
        res = Job.GetString
        Log("Response from server: " & res)
        'Log(decode(res))
        Dim strResult As String
        Dim su As StringUtils
        Dim bt() As Byte
        Dim bc As ByteConverter
        Log("Pass1: " & res)
        bt =su.DecodeBase64(res)
        Log(bt.Length)
        strResult = bc.StringFromBytes(bt, "UTF8")
        Log(strResult)

The server response in correct mode:

Response from server: W3siaWRfdXRlbnRlIjoiMTM0IiwiaWRfcGl6emVyaWEiOiIxMiIsImNvc3RvX2NvbnNlZ25hIjoiMC4wMCIsInRpcG9fZGlfY29uc2VnbmEiOiIwIiwibm9tZV9waXp6ZXJpYSI6bnVsbCwibm9tZV9jb2dub21lIjoiTUFSQ08gQU1JQ0kiLCJudW1lcm9fdGVsZWZvbmljbyI6IjMzNDMzNjcxMDUiLCJpbmRpcml6em8iOiJWSUEgREVMIE1BVFRBVE9JTyIsInBhc3N3b3JkIjoiMTIzNCJ9XQ==

and as result in bt.lenght = 0 and strResult = "empty string"

but if i put in

bt = su.DecodeBase64("W3siaWRfdXRlbnRlIjoiMTM0IiwiaWRfcGl6emVyaWEiOiIxMiIsImNvc3RvX2NvbnNlZ25hIjoiMC4wMCIsInRpcG9fZGlfY29uc2VnbmEiOiIwIiwibm9tZV9waXp6ZXJpYSI6bnVsbCwibm9tZV9jb2dub21lIjoiTUFSQ08gQU1JQ0kiLCJudW1lcm9fdGVsZWZvbmljbyI6IjMzNDMzNjcxMDUiLCJpbmRpcml6em8iOiJWSUEgREVMIE1BVFRBVE9JTyIsInBhc3N3b3JkIjoiMTIzNCJ9XQ==")

Work. Why ???
I really do not understand

P.S. Erel i send your support also example. Thank you

Bye
Marco
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Erel.
Right the first step ( res ) = 230 as Lengh, the second step ( s ) = 228.

res = res.Trim

So resolve also, DecodeBase64 / DecompressBytes

By why this ?
 
Upvote 0
Top