-// Translates '<' to "<", '>' to ">" and '&' to "&"
-bool OutputStringEnt(wxOutputStream& stream,
- const wxString& str,
- wxMBConv *convMem,
- wxMBConv *convFile,
- int flags = 0)
-{
- const size_t len = str.length();
- size_t i,
- last = 0;
- for (i = 0; i < len; i++)
- {
- wxChar c = str.GetChar(i);
- if (c == wxS('<') || c == wxS('>') ||
- (c == wxS('&') && str.substr(i+1, 4) != wxS("amp;")) ||
- ((flags & XML_ESCAPE_QUOTES) && c == wxS('"')))
- {
- if ( !OutputString(stream, str.substr(last, i - last),
- convMem, convFile) )
- return false;
+// Translates '<' to "<", '>' to ">" and so on, according to the spec:
+// http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
+bool OutputEscapedString(wxOutputStream& stream,
+ const wxString& str,
+ wxMBConv *convMem,
+ wxMBConv *convFile,
+ EscapingMode mode)
+{
+ wxString escaped;
+ escaped.reserve(str.length());