Sample code for 30+ languages & platforms
C++

HTML Encoding

Demonstrates HTML encoding and decoding.

Chilkat C++ Downloads

C++
#include <CkCrypt2.h>

void ChilkatSample(void)
    {
    CkCrypt2 crypt;

    const char *s = "< é ü ç Ω Hello & World ✓ >";

    const char *htmlEncoded = crypt.encodeString(s,"utf-8","html");
    std::cout << htmlEncoded << "\r\n";

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

    //  To decode:
    s = crypt.decodeString(htmlEncoded,"utf-8","html");
    std::cout << s << "\r\n";

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