docs: private void writeQuotedAndEscaped(CharSequence string) {
          if (string != null && string.length() != 0) {
              int len = string.length();
              writer.write('\"');
  
              for (int i = 0; i < len; ++i) {
                  char cp = string.charAt(i);
                  if ((cp < 0x7f &&
                       cp >= 0x20 &&
                       cp != '\"' &&
                       cp != '\\') ||
                      (cp > 0x7f &&
                       isConsolePrintable(cp) &&
                       !isSurrogate(cp))) {
                      // quick bypass for direct printable chars.
                      writer.write(cp);
                  } else {
                      switch (cp) {
                          case '\b':
                              writer.write("\\b");
                              break;
                          case '\t':
                              writer.write("\\t");
                              break;
                          case '\n':
                              writer.write("\\n");
                              break;
                          case '\f':
                              writer.write("\\f");
                              break;
                          case '\r':
                              writer.write("\\r");
                              break;
                          case '\"':
                          case '\\':
                              writer.write('\\');
                              writer.write(cp);
                              break;
                          default:
                              if (isSurrogate(cp) && (i + 1) < len) {
                                  char c2 = string.charAt(i + 1);
                                  writer.format("\\u%04x", (int) cp);
                                  writer.format("\\u%04x", (int) c2);
                                  ++i;
                              } else {
                                  writer.format("\\u%04x", (int) cp);
                              }
                              break;
                      }
                  }
              }
  
              writer.write('\"');
          } else {
              writer.write("\"\"");
          }
      }