B4X
B4X
Append Encoded Binary Data to StringBuilder
Demonstrates how to append encoded binary data to the contenets of a StringBuilder.Chilkat B4X Downloads
Dim success As Boolean = False
Dim bd As ChilkatBinData
bd.Initialize
success = bd.LoadFile("qa_data/jpg/starfish.jpg")
If success = False Then
Log("Failed to load file.")
Return
End If
' For example, let's say we want construct simple JSON containing the base64 representation of the above JPG file.
Dim sb As ChilkatStringBuilder
sb.Initialize
sb.Append("{ " & Chr(34) & "jpg" & Chr(34) & ": " & Chr(34))
' GetEncodedSb appends the enocded representation of the binary data to the StringBuiler passed in the 2nd arg.
bd.GetEncodedSb("base64", sb)
sb.Append(Chr(34) & " }")
Log(sb.GetAsString)
' Output looks like this:
' { "jpg": "/9j/4AAQSkZJRgABAg...rcQ+vo//2Q==" }