(Visual FoxPro) Append Encoded Binary Data to StringBuilder
Demonstrates how to append encoded binary data to the contenets of a StringBuilder.
LOCAL loBd
LOCAL lnSuccess
LOCAL loSb
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.BinData')
loBd = CreateObject('Chilkat.BinData')
lnSuccess = loBd.LoadFile("qa_data/jpg/starfish.jpg")
IF (lnSuccess = 0) THEN
? "Failed to load file."
RELEASE loBd
CANCEL
ENDIF
* For example, let's say we want construct simple JSON containing the base64 representation of the above JPG file.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSb = CreateObject('Chilkat.StringBuilder')
loSb.Append('{ "jpg": "')
* GetEncodedSb appends the enocded representation of the binary data to the StringBuiler passed in the 2nd arg.
loBd.GetEncodedSb("base64",loSb)
loSb.Append('" }')
? loSb.GetAsString()
* Output looks like this:
* { "jpg": "/9j/4AAQSkZJRgABAg...rcQ+vo//2Q==" }
RELEASE loBd
RELEASE loSb
|