Visual FoxPro
Visual FoxPro
Append Encoded Binary Data to StringBuilder
Demonstrates how to append encoded binary data to the contenets of a StringBuilder.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loBd
LOCAL loSb
lnSuccess = 0
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.
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