W3cubDocs

/Dart 2

HtmlEscape class

Converter which escapes characters with special meaning in HTML.

The converter finds characters that are significant 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

Constructors

HtmlEscape([HtmlEscapeMode mode = HtmlEscapeMode.unknown ])
const
Create converter that escapes HTML characters. [...]

Properties

modeHtmlEscapeMode
final
The HtmlEscapeMode used by the converter.
hashCodeint
read-only, inherited
The hash code for this object. [...]
runtimeTypeType
read-only, inherited
A representation of the runtime type of the object.

Methods

convert(String text) → String
override
Converts input and returns the result of the conversion.
startChunkedConversion(Sink<String> sink) → StringConversionSink
override
Starts a chunked conversion. [...]
bind(Stream<String> stream) → Stream<String>
inherited
Transforms the provided stream. [...]
cast<RS, RT>() → Converter<RS, RT>
inherited
Provides a Converter<RS, RT> view of this stream transformer. [...]
fuse<TT>(Converter<String, TT> other) → Converter<String, TT>
inherited
Fuses this with other. [...]
noSuchMethod(Invocation invocation) → dynamic
inherited
Invoked when a non-existent method or property is accessed. [...]
toString() → String
inherited
Returns a string representation of this object.

Operators

operator ==(dynamic other) → bool
inherited
The equality operator. [...]

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-convert/HtmlEscape-class.html