#include <unordered_map>#include <algorithm>#include <cstring>#include <boost/algorithm/string/case_conv.hpp>#include <boost/algorithm/string/trim.hpp>#include <boost/regex.hpp>#include <ssrc/wispers/utility/WebStrings.h>
Go to the source code of this file.
Defines | |
| #define | FROM_HEX(c) (((c) >= 'A') ? (((c) & 0xdf) - 'A' + 10) : ((c) - '0')) |
Functions | |
| __BEGIN_NS_SSRC_WSPR_UTILITY void | escape_javascript (string &result, const char *text, const unsigned int text_size) |
| void | escape_html (string &result, const char *text, const unsigned int text_size) |
| Escapes characters in text that could result in rendering HTML when passed to an HTML renderer. | |
| void | escape_url (string &result, const char *text, const unsigned int text_size) |
| Escapes characters in text that are either reserved or "unsafe" according to RFC 1738. | |
| void | unescape_url (string &url) |
| Unescapes URL escape sequences in place. | |
| void | strip_html (string &result, const char *text, const unsigned int text_size) |
| Removes all HTML tags from text. | |
| void | strip_html_and_unescape (string &result, const char *text, const unsigned int text_size) |
| Removes all HTML tags from text and unescapes character entities, converting them into the characters they represent. | |
| void | wrap_lines (char *text, const unsigned int text_size, const unsigned int max_length) |
| Replaces spaces in text with newlines in such a manner that no line exceeds a specified maximum length, except for sequences of characters uninterrupted by spaces that exceed the maximum line length. | |
| title_body_type | html_title_and_body (const char *begin, const char *end) |
| Returns the offsets of the title and body of an HTML document. | |
Define Documentation
| #define FROM_HEX | ( | c | ) | (((c) >= 'A') ? (((c) & 0xdf) - 'A' + 10) : ((c) - '0')) |
Referenced by unescape_url().
Function Documentation
| void escape_html | ( | string & | result, |
| const char * | text, | ||
| const unsigned int | text_size | ||
| ) |
Escapes characters in text that could result in rendering HTML when passed to an HTML renderer.
In addition, all leading and trailing whitespace is removed.
- Parameters:
-
result Buffer in which to store escaped text. The string will be resized to hold the text. text The text to be escaped. text_size The length of the unescaped text.
Definition at line 410 of file WebStrings.cc.
Referenced by escape_html().
| __BEGIN_NS_SSRC_WSPR_UTILITY void escape_javascript | ( | string & | result, |
| const char * | text, | ||
| const unsigned int | text_size | ||
| ) |
Definition at line 392 of file WebStrings.cc.
Referenced by escape_javascript().
| void escape_url | ( | string & | result, |
| const char * | text, | ||
| const unsigned int | text_size | ||
| ) |
Escapes characters in text that are either reserved or "unsafe" according to RFC 1738.
Trailing spaces are escaped and not trimmed.
- Parameters:
-
result Buffer in which to store escaped text. The string will be resized to hold the text. text The text to be escaped. text_size The length of the unescaped text.
Definition at line 427 of file WebStrings.cc.
Referenced by escape_url().
| title_body_type html_title_and_body | ( | const char * | begin, |
| const char * | end | ||
| ) |
Returns the offsets of the title and body of an HTML document.
Definition at line 603 of file WebStrings.cc.
| void strip_html | ( | string & | result, |
| const char * | text, | ||
| const unsigned int | text_size | ||
| ) |
Removes all HTML tags from text.
- Parameters:
-
result Buffer in which to store stripped text. The string will be resized to hold the text. text The text to be stripped. text_size The length of the unstripped text.
Definition at line 475 of file WebStrings.cc.
Referenced by strip_html().
| void strip_html_and_unescape | ( | string & | result, |
| const char * | text, | ||
| const unsigned int | text_size | ||
| ) |
Removes all HTML tags from text and unescapes character entities, converting them into the characters they represent.
- Parameters:
-
result Buffer in which to store stripped text. The string will be resized to hold the text. text The text to be stripped. text_size The length of the unstripped text.
Definition at line 517 of file WebStrings.cc.
Referenced by strip_html_and_unescape().
| void unescape_url | ( | string & | url | ) |
Unescapes URL escape sequences in place.
- Parameters:
-
url The URL to unescape.
Definition at line 439 of file WebStrings.cc.
References FROM_HEX.
Referenced by parse_query_string().
| void wrap_lines | ( | char * | text, |
| const unsigned int | text_size, | ||
| const unsigned int | max_length | ||
| ) |
Replaces spaces in text with newlines in such a manner that no line exceeds a specified maximum length, except for sequences of characters uninterrupted by spaces that exceed the maximum line length.
- Parameters:
-
text The text to be line-wrapped. text_size The length of the text. max_length The maximum line length.
Definition at line 563 of file WebStrings.cc.