escapeIcu method

String escapeIcu()

Implementation

String escapeIcu() {
  // Escape '' first
  var replaced = replaceAll("''", "__‹ESC_QUOTE›__");

  // Escape '{...}' if enclosed in single quotes
  replaced = replaced.replaceAllMapped(
    RegExp(r"'(\{[^}]+\})'"),
    (match) => match
        .group(1)!
        .replaceAll('{', '__‹ESC_OPEN›__')
        .replaceAll('}', '__‹ESC_CLOSE›__'),
  );

  return replaced;
}