convertFancyQuotes static method
Implementation
static String convertFancyQuotes(String string) => string
.replaceAllMapped(RegExp(r'[\u2018\u2019\u201C\u201D\u2014]'), (match) {
switch (match.group(0)) {
case '\u2018': // left single quote (‘)
case '\u2019': // right single quote (’)
return "'";
case '\u201C': // left double quote (“)
case '\u201D': // right double quote (”)
return '"';
case '\u2014': // em dash (—)
return '-';
default:
return match.group(0)!;
}
})
.replaceAll(r'\n', '')
.replaceAll(r'\\\"', "<backslash">")
.replaceAll(r'\', '')
.replaceAll(r'<backslash">', r'\"');