Go to the documentation of this file.
19 static auto escapeMap =
new std::array<SBuf, 256> {};
20 auto &em = *escapeMap;
21 if (!em[
'<'].isEmpty())
26 for (
int ch = 0; ch < 256; ++ch) {
27 if ((ch <= 0x1F || ch >= 0x7f) && ch !=
'\n' && ch !=
'\r' && ch !=
'\t') {
45 static char *buf =
nullptr;
46 static size_t bufsize = 0;
53 if (!buf || strlen(
string) * 6 > bufsize) {
55 bufsize = strlen(
string) * 6 + 1;
56 buf =
static_cast<char *
>(
xcalloc(bufsize, 1));
58 for (src =
string, dst = buf; *src; src++) {
59 const unsigned char ch = *src;
61 const auto &escape = escapeSequences[ch];
62 if (!escape.isEmpty()) {
65 dst += escape.length();
void * xcalloc(size_t n, size_t sz)
static const auto & EscapeSequences()
char * html_quote(const char *string)
SBuf & Printf(const char *fmt,...) PRINTF_FORMAT_ARG2