code: static void unescapeBraceFormat(StringBuilder out, String message, int start, int end) {
      int pos = start;
      boolean isQuoted = false;
      while (pos < end) {
        char c = message.charAt(pos++);
        // We catch single quotes and escaped single quotes.
        if (c != '\\' && c != '\'') {
          continue;
        }
        int quoteStart = pos - 1;
        if (c == '\\') {
          // Shouldn't risk index out of bounds here because that would be a trailing single '\'.
          c = message.charAt(pos++);
          if (c != '\'') {
            continue;
          }
        }
        // Always skip the first single-quote we find.
        out.append(message, start, quoteStart);
        start = pos;
        if (pos == end) {
          break;
        }
        if (isQuoted) {
          isQuoted = false;
        } else if (message.charAt(pos) != '\'') {
          isQuoted = true;
        } else {
          // If there are two adjacent single-quotes, advance our position so we don't detect it
          // when we go back to the top of the loop (this does mean reading that same char twice
          // if it wasn't a single quote, but this is relatively rare).
          pos++;
        }
      }
      // Append the last section (if it's non empty).
      if (start < end) {
        out.append(message, start, end);
      }
    }
docs: VisibleForTesting