Sample code for 30+ languages & platforms
Unicode C

StringBuilder GetEncoded

Demonstrates the Chilkat StringBuilder GetEncoded method.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkStringBuilderW.h>

void ChilkatSample(void)
    {
    const wchar_t *s;
    HCkStringBuilderW sb;

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

    sb = CkStringBuilderW_Create();

    CkStringBuilderW_Append(sb,s);

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

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

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


    CkStringBuilderW_Dispose(sb);

    }