Sample code for 30+ languages & platforms
C

StringBuilder GetEncoded

Demonstrates the Chilkat StringBuilder GetEncoded method.

Chilkat C Downloads

C
#include <C_CkStringBuilder.h>

void ChilkatSample(void)
    {
    const char *s;
    HCkStringBuilder sb;

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

    sb = CkStringBuilder_Create();

    CkStringBuilder_Append(sb,s);

    //  output: The quick brown fox jumps over the lazy dog
    printf("%s\n",CkStringBuilder_getAsString(sb));

    //  Get the string encoded to base64, without changing the contents of sb.
    //  output: VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==
    printf("%s\n",CkStringBuilder_getEncoded(sb,"base64","utf-8"));

    //  The contents of sb are not changed..
    //  output: The quick brown fox jumps over the lazy dog
    printf("%s\n",CkStringBuilder_getAsString(sb));


    CkStringBuilder_Dispose(sb);

    }