class Builder::XmlBase

def _escape(text)

def _escape(text)
  result = XChar.encode(text)
  begin
    result.encode(@encoding)
  rescue
    # if the encoding can't be supported, use numeric character references
    result.
      gsub(/[^\u0000-\u007F]/) {|c| "&##{c.ord};"}.
      force_encoding('ascii')
  end
end