Hello, this is my first post on this forum, hope it works out
I'm trying to do HTML entity decoding in C++, couldn't find any existing text out there to help out. Hows this look? It works on a small scale, but with lots of text it tends to stumble, even lock some times. Any ideas on performance here, or what I might be doing wrong?
Thanks in advance!
Code:string htmlEntitiesDecode (string str) { string subs[] = { """, """, "'", "'", "&", "&", "<", "<", ">", ">" }; string reps[] = { "\"", "\"", "'", "'", "&", "&", "<", "<", ">", ">" }; size_t found; for(int j = 0; j <= 10; j++) { do { found = str.rfind(subs[j]); if (found != string::npos) str.replace (found,subs[j].length(),reps[j]); } while (found != string::npos); } return str; }





Reply With Quote