private static void appendReplacingNewLines(StringBuilder out, CharSequence value) {
    if (value == null) {
      out.append("null");
      return;
    }

    int appendFrom = 0;
    int length = value.length();
    for (int i = 0; i < length; i++) {
      char ch = value.charAt(i);
      if (ch == '\n') {
        out.append(value.subSequence(appendFrom, i));

        if (i < length - 1 && value.charAt(i + 1) == '\r') {
          //noinspection AssignmentToForLoopParameter
          i++;
        }
        out.append(NEWLINE);
        appendFrom = i + 1;
      }
    }
    if (appendFrom == 0) {
      out.append(value);
    }
    else {
      out.append(value.subSequence(appendFrom, value.length()));
    }
  }
private static void appendReplacingNewLines(StringBuilder out, CharSequence value)