Base64DecodeFromVariantStr - cCharTranslate

Decodes a base 64 encoded Variant String and places it in a newly created memory buffer

Type: Function

Return Data Type: Pointer

Parameters: Variant vBase64Str Integer ByRef iBinaryLen

ParameterDescription
vBase64StrVariant String as Base64
iBinaryLen (ByRef)Returns the length of the binary buffer


Return Value

The buffer address of the decoded string


Syntax
Function Base64DecodeFromVariantStr Variant vBase64Str Integer ByRef iBinaryLen Returns Pointer

Call: Get Base64DecodeFromVariantStr vBase64Str (&iBinaryLen) to PointerVariable


Description

Base64DecodeFromVariantStr decodes a base 64 encoded Variant String and places it in a newly created memory buffer.

You are responsible for eventually disposing of the newly created memory buffer.

This is often paired with Base64EncodeToVariantStr.

See discussion in the cCharTranslate class overview about the advantages and disadvantage of using the Variant String type.

Use Windows.pkg
Use cCharTranslate.pkg
 
Object oCharTranslate is a cCharTranslate
End_Object
 
Procedure TestBase64EncodeVariantStr
    Pointer aBinary aBinary2
    Integer iVoid iLen iLen2
    Variant vVar
    String sData sData2
        
    // aBinary could be any binary data of length iLen. 
    Move "Pretend this is actually binary data" to sData
    Move (AddressOf(sData)) to aBinary
    Move (SizeOfString(sData)) to iLen

    // base64Encode to variant
    Get Base64EncodeToVariantStr of oCharTranslate aBinary iLen to vVar
    
    // Base64 decode from variant
    Get Base64DecodeFromVariantStr of oCharTranslate vVar (&iLen2) to aBinary2
    If (iLen<>iLen2 or MemCompare(aBinary,aBinary2,iLen2)) Begin
        Send Info_Box "Test Failed"
    End
    
    Move (Free(aBinary2)) to iVoid
End_Procedure

Send TestBase64EncodeVariantStr

See Also

Base64EncodeToStr | Base64DecodeFromStr | Base64EncodeToVariantStr | Base64Encode | Base64Decode Free()