unescape static method

String unescape(
  1. String value
)

Implementation

static String unescape(String value) {
  if (!value.contains("&")) return value;
  return value
      .replaceAllMapped(RegExp("&#x([0-9a-fA-F]+);"), (Match m) => String.fromCharCode(int.parse(m.group(1)!, radix: 16)))
      .replaceAllMapped(RegExp(r"&#(\d+);"), (Match m) => String.fromCharCode(int.parse(m.group(1)!)))
      .replaceAll("&lt;", "<")
      .replaceAll("&gt;", ">")
      .replaceAll("&quot;", "\"")
      .replaceAll("&apos;", "'")
      .replaceAll("&amp;", "&");
}