Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:convert
  3. HtmlEscapeMode class
HtmlEscapeMode
description

HtmlEscapeMode classfinal

HTML escape modes.

Allows specifying a mode for HTML escaping that depends on the contextwhere the escaped result is going to be used.The relevant contexts are:

  • as text content of an HTML element.
  • as value of a (single- or double-) quoted attribute value.

All modes require escaping of& (ampersand) characters, and mayenable escaping of more characters.

Custom escape modes can be created using theHtmlEscapeMode.newconstructor.

Example:

const htmlEscapeMode = HtmlEscapeMode(  name: 'custom',  escapeLtGt: true,  escapeQuot: false,  escapeApos: false,  escapeSlash: false, );const HtmlEscape htmlEscape = HtmlEscape(htmlEscapeMode);String unescaped = 'Text & subject';String escaped = htmlEscape.convert(unescaped);print(escaped); // Text &amp; subjectunescaped = '10 > 1 and 1 < 10';escaped = htmlEscape.convert(unescaped);print(escaped); // 10 &gt; 1 and 1 &lt; 10unescaped = "Single-quoted: 'text'";escaped = htmlEscape.convert(unescaped);print(escaped); // Single-quoted: 'text'unescaped = 'Double-quoted: "text"';escaped = htmlEscape.convert(unescaped);print(escaped); // Double-quoted: "text"unescaped = 'Path: /system/';escaped = htmlEscape.convert(unescaped);print(escaped); // Path: /system/

Constructors

HtmlEscapeMode({Stringname ="custom",boolescapeLtGt =false,boolescapeQuot =false,boolescapeApos =false,boolescapeSlash =false})
Create a custom escaping mode.
const

Properties

escapeAposbool
Whether to escape "'" (apostrophe).
final
escapeLtGtbool
Whether to escape '<' and '>'.
final
escapeQuotbool
Whether to escape '"' (quote).
final
escapeSlashbool
Whether to escape "/" (forward slash, solidus).
final
hashCodeint
The hash code for this object.
no setterinherited
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString()String
A string representation of this object.
override

Operators

operator ==(Objectother)bool
The equality operator.
inherited

Constants

attribute→ constHtmlEscapeMode
Escaping mode for text going into double-quoted HTML attribute values.
element→ constHtmlEscapeMode
Escaping mode for text going into HTML element content.
sqAttribute→ constHtmlEscapeMode
Escaping mode for text going into single-quoted HTML attribute values.
unknown→ constHtmlEscapeMode
Default escaping mode, which escapes all characters.
  1. Dart
  2. dart:convert
  3. HtmlEscapeMode class
dart:convert library

[8]ページ先頭

©2009-2025 Movatter.jp