unquoteDoubleQuotes function
Unquotes and unescapes a String escaped and quoted with double quotes.
Implementation
String unquoteDoubleQuotes(String string) {
var isValid = () {
bool run = false;
for (var ch in string.codeUnits)
if (ch == 34)
run = !run;
else if (!run)
return false;
return !run;
};
if (string.isEmpty || !isValid())
throw FormatException(
"unquoteDoubleQuotes: "
"expected a string escaped and quoted with double quotes",
string,
);
return string.substring(1, string.length - 1).replaceAll("\"\"", "\"");
}