Dart API Referencedart:web

dart:web library

Methods

Code String htmlEscape(String text) #

Escapes HTML-special characters of text so that the result can be included verbatim in HTML source code, either in an element body or in an attribute value.

String htmlEscape(String text) {
  // TODO(efortuna): A more efficient implementation.
  return text.replaceAll("&", "&")
             .replaceAll("<", "&lt;")
             .replaceAll(">", "&gt;")
             .replaceAll('"', "&quot;")
             .replaceAll("'", "&apos;");
}