code: private static <T extends Appendable> T _appendToPat(T buf, int c, boolean escapeUnprintable) {
          try {
              if (escapeUnprintable && Utility.isUnprintable(c)) {
                  // Use hex escape notation (<backslash>uxxxx or <backslash>Uxxxxxxxx) for anything
                  // unprintable
                  if (Utility.escapeUnprintable(buf, c)) {
                      return buf;
                  }
              }
              // Okay to let ':' pass through
              switch (c) {
              case '[': // SET_OPEN:
              case ']': // SET_CLOSE:
              case '-': // HYPHEN:
              case '^': // COMPLEMENT:
              case '&': // INTERSECTION:
              case '\\': //BACKSLASH:
              case '{':
              case '}':
              case '$':
              case ':':
                  buf.append('\\');
                  break;
              default:
                  // Escape whitespace
                  if (PatternProps.isWhiteSpace(c)) {
                      buf.append('\\');
                  }
                  break;
              }
              appendCodePoint(buf, c);
              return buf;
          } catch (IOException e) {
              throw new ICUUncheckedIOException(e);
          }
      }
docs: Append the <code>toPattern()</code> representation of a
  character to the given <code>Appendable</code>.