-docstring escapeChar(char c, XMLStream::EscapeSettings e) {
- LATTEST(static_cast<unsigned char>(c) < 0x80);
- return escapeChar(static_cast<char_type>(c), e);
+docstring escapeString(docstring const & raw, XMLStream::EscapeSettings e)
+{
+ docstring bin;
+ bin.reserve(raw.size() * 2); // crude approximation is sufficient
+ for (size_t i = 0; i != raw.size(); ++i) {
+ char_type c = raw[i];
+ if (e == XMLStream::ESCAPE_COMMENTS && c == '-' && i > 0 && raw[i - 1] == '-')
+ bin += "-";
+ else
+ bin += xml::escapeChar(c, e);
+ }
+
+ return bin;