code: private final static String escape(String src) {
          if (src == null) {
              return "";
          }
          StringBuffer result = null;
          for (int i = 0, max = src.length(), delta = 0; i < max; i++) {
              char c = src.charAt(i);
              if (!Character.isWhitespace(c) && Character.isISOControl(c) || Character.getType(c) == Character.UNASSIGNED) {
                  String hexVal = Integer.toHexString(c);
                  String replacement = "\\u" + ("0000" + hexVal).substring(hexVal.length());
                  if (result == null) {
                      result = new StringBuffer(src);
                  }
                  result.replace(i + delta, i + delta + 1, replacement);
                  delta += replacement.length() - 1;
              }
          }
          if (result == null) {
              return src;
          } else {
              return result.toString();
          }
      }
docs: D512713 - method to convert non-printable chars into a printable string for the log.