Sample code for 30+ languages & platforms
AutoIt

Append Encoded Binary Data to StringBuilder

Demonstrates how to append encoded binary data to the contenets of a StringBuilder.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oBd = ObjCreate("Chilkat.BinData")

$bSuccess = $oBd.LoadFile("qa_data/jpg/starfish.jpg")
If ($bSuccess = False) Then
    ConsoleWrite("Failed to load file." & @CRLF)
    Exit
EndIf

; For example, let's say we want construct simple JSON containing the base64 representation of the above JPG file.
$oSb = ObjCreate("Chilkat.StringBuilder")
$oSb.Append("{ ""jpg"": """)
; GetEncodedSb appends the enocded representation of the binary data to the StringBuiler passed in the 2nd arg.
$oBd.GetEncodedSb("base64",$oSb)
$oSb.Append(""" }")

ConsoleWrite($oSb.GetAsString() & @CRLF)

; Output looks like this:
;  { "jpg": "/9j/4AAQSkZJRgABAg...rcQ+vo//2Q==" }