Sample code for 30+ languages & platforms
Unicode C++

HTML Entity Encode and Decode in StringBuilder

Demonstrates HTML encoding and decoding the contents of a StringBuilder.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkStringBuilderW.h>

void ChilkatSample(void)
    {
    CkStringBuilderW sb;

    const wchar_t *s = L"< é ü ç Ω Hello & World ✓ >";
    sb.Append(s);

    sb.Encode(L"html",L"utf-8");
    wprintf(L"%s\n",sb.getAsString());

    //  Output:
    //  < &eacute; &uuml; &ccedil; &ohm; Hello & World &check; >

    //  To decode:
    sb.Decode(L"html",L"utf-8");
    wprintf(L"%s\n",sb.getAsString());

    //  Output:
    //  < é ü ç Ω Hello & World ✓ >
    }