void WriteEscapedString (string text, bool isAttribute)
{
char [] escaped = isAttribute ?
escaped_attr_chars : escaped_text_chars;
int idx = text.IndexOfAny (escaped);
if (idx >= 0) {
char [] arr = text.ToCharArray ();
WriteCheckedBuffer (arr, 0, idx);
WriteEscapedBuffer (
arr, idx, arr.Length - idx, isAttribute);
} else {
WriteCheckedString (text);
}
}