code: public static String escapeCharLiteral(char c) {
      if (c >= 0x20 && c <= 0x7E) { // if ASCII
        switch (c) {
          case '\'': return "'\\''";
          case '\\': return "'\\\\'";
        }
        return "'" + c + "'";
      } else {
        return UnicodeUtils.format("0x%04x", (int) c);
      }
    }
docs: Returns a valid C/C++ character literal (including quotes).