+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;
+}
+
+