2015-04-12 21:35:13 +08:00
|
|
|
#include "utils.hpp"
|
2015-04-10 02:41:27 +08:00
|
|
|
|
2015-04-12 21:25:16 +08:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
2015-04-10 02:41:27 +08:00
|
|
|
|
2015-04-16 04:32:27 +08:00
|
|
|
mstch::citer mstch::first_not_ws(mstch::citer begin, mstch::citer end) {
|
|
|
|
for(auto it = begin; it != end; ++it)
|
|
|
|
if(*it != ' ') return it;
|
|
|
|
return end;
|
|
|
|
}
|
|
|
|
|
|
|
|
mstch::citer mstch::first_not_ws(mstch::criter begin, mstch::criter end) {
|
|
|
|
for(auto rit = begin; rit != end; ++rit)
|
|
|
|
if(*rit != ' ') return --(rit.base());
|
|
|
|
return --(end.base());
|
|
|
|
}
|
|
|
|
|
2015-04-10 02:41:27 +08:00
|
|
|
std::string mstch::html_escape(std::string str) {
|
2015-04-12 21:25:16 +08:00
|
|
|
boost::replace_all(str, "&", "&");
|
|
|
|
boost::replace_all(str, "'", "'");
|
|
|
|
boost::replace_all(str, "\"", """);
|
|
|
|
boost::replace_all(str, "<", "<");
|
|
|
|
boost::replace_all(str, ">", ">");
|
|
|
|
boost::replace_all(str, "/", "/");
|
2015-04-10 02:41:27 +08:00
|
|
|
return str;
|
|
|
|
}
|