unescapeBackslash method

String unescapeBackslash(
  1. String escaped
)

Implementation

String unescapeBackslash(String escaped) {
  final backslash = escaped.indexOf('\\');
  if (backslash < 0) {
    return escaped;
  }
  final max = escaped.length;
  final unescaped = StringBuffer();
  unescaped.write(escaped.substring(0, backslash));
  bool nextIsEscaped = false;
  for (int i = backslash; i < max; i++) {
    final c = escaped[i];
    if (nextIsEscaped || c != '\\') {
      unescaped.write(c);
      nextIsEscaped = false;
    } else {
      nextIsEscaped = true;
    }
  }
  return unescaped.toString();
}