summaryrefslogtreecommitdiffstats
path: root/src/htmlgen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/htmlgen.cpp')
-rw-r--r--src/htmlgen.cpp55
1 files changed, 40 insertions, 15 deletions
diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp
index 3a92020..58a0622 100644
--- a/src/htmlgen.cpp
+++ b/src/htmlgen.cpp
@@ -60,6 +60,7 @@ static QCString g_header;
static QCString g_footer;
static QCString g_mathjax_code;
static QCString g_latex_macro;
+static const char *hex="0123456789ABCDEF";
// note: this is only active if DISABLE_INDEX=YES, if DISABLE_INDEX is disabled, this
// part will be rendered inside menu.js
@@ -672,9 +673,21 @@ void HtmlCodeGenerator::codify(const char *str)
m_t << "\\";
m_col++;
break;
- default: p=writeUtf8Char(m_t,p-1);
- m_col++;
- break;
+ default:
+ {
+ uchar uc = static_cast<uchar>(c);
+ if (uc<32)
+ {
+ m_t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
+ m_col++;
+ }
+ else
+ {
+ p=writeUtf8Char(m_t,p-1);
+ m_col++;
+ }
+ }
+ break;
}
}
}
@@ -698,18 +711,30 @@ void HtmlCodeGenerator::docify(const char *str)
case '&': m_t << "&amp;"; break;
case '"': m_t << "&quot;"; break;
case '\\':
- if (*p=='<')
- { m_t << "&lt;"; p++; }
- else if (*p=='>')
- { m_t << "&gt;"; p++; }
- else if (*p=='(')
- { m_t << "\\&zwj;("; p++; }
- else if (*p==')')
- { m_t << "\\&zwj;)"; p++; }
- else
- m_t << "\\";
- break;
- default: m_t << c;
+ if (*p=='<')
+ { m_t << "&lt;"; p++; }
+ else if (*p=='>')
+ { m_t << "&gt;"; p++; }
+ else if (*p=='(')
+ { m_t << "\\&zwj;("; p++; }
+ else if (*p==')')
+ { m_t << "\\&zwj;)"; p++; }
+ else
+ m_t << "\\";
+ break;
+ default:
+ {
+ uchar uc = static_cast<uchar>(c);
+ if (uc<32 && !isspace(c))
+ {
+ m_t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
+ }
+ else
+ {
+ m_t << c;
+ }
+ }
+ break;
}
}
}