How can I decode HTML entities in C++?
For example:
HTML: "Music" & "video"
Decoded: "Music" &
If you're comfortable with using C-strings, you might be interested in my answer to a similar question.
There's no need to compile the code as C++: compile entities.c
as -std=c99
and link the object file with your C++ code, eg if you have the follwing example program foo.cpp
#include <iostream>
extern "C" size_t decode_html_entities_utf8(char *dest, const char *src);
int main()
{
char line[100];
std::cout << "Enter encoded line: ";
std::cin.getline(line, sizeof line);
decode_html_entities_utf8(line, 0);
std::cout << line;
return 0;
}
use
g++ -o foo foo.cpp entities.o