Sample code for 30+ languages & platforms
PureBasic

StringBuilder GetEncoded

Demonstrates the Chilkat StringBuilder GetEncoded method.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkStringBuilder.pb"

Procedure ChilkatExample()

    s.s = "The quick brown fox jumps over the lazy dog"

    sb.i = CkStringBuilder::ckCreate()
    If sb.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkStringBuilder::ckAppend(sb,s)

    ; output: The quick brown fox jumps over the lazy dog
    Debug CkStringBuilder::ckGetAsString(sb)

    ; Get the string encoded to base64, without changing the contents of sb.
    ; output: VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==
    Debug CkStringBuilder::ckGetEncoded(sb,"base64","utf-8")

    ; The contents of sb are not changed..
    ; output: The quick brown fox jumps over the lazy dog
    Debug CkStringBuilder::ckGetAsString(sb)


    CkStringBuilder::ckDispose(sb)


    ProcedureReturn
EndProcedure