Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
escape_html.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/string/escape_html.cpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2007-2017 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
12 
13 namespace tlx {
14 
16  std::string os;
17  os.reserve(str.size() + str.size() / 16);
18 
19  for (std::string::const_iterator si = str.begin(); si != str.end(); ++si)
20  {
21  if (*si == '&') os += "&amp;";
22  else if (*si == '<') os += "&lt;";
23  else if (*si == '>') os += "&gt;";
24  else if (*si == '"') os += "&quot;";
25  else os += *si;
26  }
27 
28  return os;
29 }
30 
31 } // namespace tlx
32 
33 /******************************************************************************/
std::string escape_html(const std::string &str)
Escape characters for inclusion in HTML documents: replaces the characters <, >, & and " with HTML en...
Definition: escape_html.cpp:15
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220