code: static void unescapePrintf(StringBuilder out, String message, int start, int end) {
      int pos = start;
      while (pos < end) {
        if (message.charAt(pos++) != '%') {
          continue;
        }
        if (pos == end) {
          // Ignore unexpected trailing '%'.
          break;
        }
        char chr = message.charAt(pos);
        if (chr == '%') {
          // Append the section up to and including the first '%'.
          out.append(message, start, pos);
        } else if (chr == 'n') {
          // %n encountered, rewind one position to not emit leading '%' and emit newline.
          out.append(message, start, pos - 1);
          out.append(SYSTEM_NEWLINE);
        } else {
          // A single unescaped '%' is ignored and left in the output as-is.
          continue;
        }
        // Increment the position and reset the start point after the last processed character.
        start = ++pos;
      }
      // Append the last section (if it's non empty).
      if (start < end) {
        out.append(message, start, end);
      }
    }
docs: VisibleForTesting