parseString function

String parseString(
  1. String string
)

Implementation

String parseString(String string) {
  final result = new StringBuffer();
  for (int i = 0; i < string.length; i++) {
    final char = string[i];
    if (char == '\\') {
      i++;
      final nextChar = string[i];
      if (nextChar == 'u') {
        result.write(parseHexEscape(safeSubstring(string, i + 1, i + 5)));
        i += 4;
      } else if (passEscapes.indexOf(nextChar) != -1) {
        result.write(nextChar);
      } else if (escapes.containsKey(nextChar)) {
        result.write(escapes[nextChar]);
      } else {
        break;
      }
    } else {
      result.write(char);
    }
  }
  return result.toString();
}