mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +02:00
src/system/helpers.cpp: Add htmlEntityDecode() for decode html string
Origin commit data
------------------
Commit: 0028ad0d9b
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2014-02-26 (Wed, 26 Feb 2014)
This commit is contained in:
@@ -417,6 +417,28 @@ std::string& str_replace(const std::string &search, const std::string &replace,
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string& htmlEntityDecode(std::string& text)
|
||||||
|
{
|
||||||
|
struct decode_table {
|
||||||
|
const char* code;
|
||||||
|
const char* htmlCode;
|
||||||
|
};
|
||||||
|
decode_table dt[] =
|
||||||
|
{
|
||||||
|
{" ", " "},
|
||||||
|
{"&", "&"},
|
||||||
|
{"<", "<"},
|
||||||
|
{">", ">"},
|
||||||
|
{"\"", """},
|
||||||
|
{"'", "'"},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
for (int i = 0; dt[i].code != NULL; i++)
|
||||||
|
text = str_replace(dt[i].htmlCode, dt[i].code, text);
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
CFileHelpers::CFileHelpers()
|
CFileHelpers::CFileHelpers()
|
||||||
{
|
{
|
||||||
FileBufSize = 0xFFFF;
|
FileBufSize = 0xFFFF;
|
||||||
|
@@ -55,6 +55,7 @@ std::string getNowTimeStr(const char* format);
|
|||||||
std::string trim(std::string &str, const std::string &trimChars = " \n\r\t");
|
std::string trim(std::string &str, const std::string &trimChars = " \n\r\t");
|
||||||
time_t toEpoch(std::string &date);
|
time_t toEpoch(std::string &date);
|
||||||
std::string& str_replace(const std::string &search, const std::string &replace, std::string &text);
|
std::string& str_replace(const std::string &search, const std::string &replace, std::string &text);
|
||||||
|
std::string& htmlEntityDecode(std::string& text);
|
||||||
|
|
||||||
class CFileHelpers
|
class CFileHelpers
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user