Sample code for 30+ languages & platforms
C++

HTML Entity Encode and Decode in StringBuilder

Demonstrates HTML encoding and decoding the contents of a StringBuilder.

Chilkat C++ Downloads

C++
#include <CkStringBuilder.h>

void ChilkatSample(void)
    {
    CkStringBuilder sb;

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

    sb.Encode("html","utf-8");
    std::cout << sb.getAsString() << "\r\n";

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

    //  To decode:
    sb.Decode("html","utf-8");
    std::cout << sb.getAsString() << "\r\n";

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