decodeEntities

Removes unwanted characters from a string, and decodes HTML entities in it (like — and  ).

version(WithWebtitlePlugin)
private
decodeEntities
(
const string line
)

Parameters

line string

String to decode entities and remove tags from.

Return Value

Type: auto

A modified string, with unwanted bits stripped out and/or decoded.

Examples

immutable t1 = ""Hello world!"";
immutable t1p = decodeEntities(t1);
assert((t1p == "\"Hello\u00A0world!\""), t1p);  // not a normal space

immutable t2 = "</title>";
immutable t2p = decodeEntities(t2);
assert((t2p == "</title>"), t2p);

immutable t3 = "&mdash;&micro;&acute;&yen;&euro;";
immutable t3p = decodeEntities(t3);
assert((t3p == "—µ´¥€"), t3p);  // not a normal dash

immutable t4 = "&quot;Se&ntilde;or &THORN;&quot; &copy;2017";
immutable t4p = decodeEntities(t4);
assert((t4p == `"Señor Þ" ©2017`), t4p);

immutable t5 = "\n        Nyheter - NSD.se        \n";
immutable t5p = decodeEntities(t5);
assert(t5p == "Nyheter - NSD.se");