code: private <T extends Appendable> T _toPattern(T result,
              boolean escapeUnprintable) {
          if (pat == null) {
              return appendNewPattern(result, escapeUnprintable, true);
          }
          try {
              if (!escapeUnprintable) {
                  result.append(pat);
                  return result;
              }
              boolean oddNumberOfBackslashes = false;
              for (int i=0; i<pat.length(); ) {
                  int c = pat.codePointAt(i);
                  i += Character.charCount(c);
                  if (Utility.isUnprintable(c)) {
                      // If the unprintable character is preceded by an odd
                      // number of backslashes, then it has been escaped
                      // and we omit the last backslash.
                      Utility.escapeUnprintable(result, c);
                      oddNumberOfBackslashes = false;
                  } else if (!oddNumberOfBackslashes && c == '\\') {
                      // Temporarily withhold an odd-numbered backslash.
                      oddNumberOfBackslashes = true;
                  } else {
                      if (oddNumberOfBackslashes) {
                          result.append('\\');
                      }
                      appendCodePoint(result, c);
                      oddNumberOfBackslashes = false;
                  }
              }
              if (oddNumberOfBackslashes) {
                  result.append('\\');
              }
              return result;
          } catch (IOException e) {
              throw new ICUUncheckedIOException(e);
          }
      }
docs: Append a string representation of this set to result.  This will be
  a cleaned version of the string passed to applyPattern(), if there
  is one.  Otherwise it will be generated.