PowerBuilder
PowerBuilder
Append Encoded Binary Data to StringBuilder
Demonstrates how to append encoded binary data to the contenets of a StringBuilder.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Bd
oleobject loo_Sb
li_Success = 0
loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")
if li_rc < 0 then
destroy loo_Bd
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Bd.LoadFile("qa_data/jpg/starfish.jpg")
if li_Success = 0 then
Write-Debug "Failed to load file."
destroy loo_Bd
return
end if
// For example, let's say we want construct simple JSON containing the base64 representation of the above JPG file.
loo_Sb = create oleobject
li_rc = loo_Sb.ConnectToNewObject("Chilkat.StringBuilder")
loo_Sb.Append("{ ~"jpg~": ~"")
// GetEncodedSb appends the enocded representation of the binary data to the StringBuiler passed in the 2nd arg.
loo_Bd.GetEncodedSb("base64",loo_Sb)
loo_Sb.Append("~" }")
Write-Debug loo_Sb.GetAsString()
// Output looks like this:
// { "jpg": "/9j/4AAQSkZJRgABAg...rcQ+vo//2Q==" }
destroy loo_Bd
destroy loo_Sb