(PureBasic) Appending Strings to BinData
Demonstrates appending strings to a BinData..
IncludeFile "CkBinData.pb"
Procedure ChilkatExample()
binData1.i = CkBinData::ckCreate()
If binData1.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Append a string using a 1-byte per char encoding
CkBinData::ckAppendString(binData1,"This is a test","windows-1252")
Debug CkBinData::ckGetEncoded(binData1,"hex")
; The bytes contained within the binData1 (in hex) are: 54,68,69,73,20,69, ...
binData2.i = CkBinData::ckCreate()
If binData2.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Append a string using a 2-byte per char encoding
CkBinData::ckAppendString(binData2,"This is a test","utf-16")
Debug CkBinData::ckGetEncoded(binData2,"hex")
; The bytes contained within the binData2 (in hex) are: 54,00,68,00,69,00,73,00,20,00,69,00, ...
CkBinData::ckDispose(binData1)
CkBinData::ckDispose(binData2)
ProcedureReturn
EndProcedure
|