Converter which escapes characters with special meaning in HTML.

The converter finds characters that are siginificant in HTML source and replaces them with corresponding HTML entities.

The characters that need escaping in HTML are:

  • & (ampersand) always need to be escaped.
  • < (less than) and '>' (greater than) when inside an element.
  • " (quote) when inside a double-quoted attribute value.
  • ' (apostrophe) when inside a single-quoted attribute value. Apostrophe is escaped as &#39; instead of &apos; since not all browsers understand &apos;.
  • / (slash) is recommended to be escaped because it may be used to terminate an element in some HTML dialects.

Escaping > (greater than) isn't necessary, but the result is often found to be easier to read if greater-than is also escaped whenever less-than is.

Inheritance
Implements

Constructors

HtmlEscape([HtmlEscapeMode mode = HtmlEscapeMode.UNKNOWN ])

Create converter that escapes HTML characters.

const

Properties

hashCode int

Get a hash code for this object.

read-only, inherited
mode HtmlEscapeMode

The HtmlEscapeMode used by the converter.

read-only
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) bool

The equality operator.

inherited

Methods

bind(Stream stream) Stream

Transform the incoming stream's events.

inherited
convert(String text) String

Converts input and returns the result of the conversion.

fuse(Converter<String, dynamic> other) Converter<String, dynamic>

Fuses this with other.

inherited
noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
startChunkedConversion(Sink<String> sink) StringConversionSink

Starts a chunked conversion.

toString() String

Returns a string representation of this object.

inherited