code: public static String encodeUTF8(int c) {
      if (c <= 0x7F) return ("" + (char) c);
      if (c <= 0x7FF) return ("" + (char) (0xC0 + ((c >> 6) & 0x1F)) + (char) (0x80 + (c & 0x3F)));
      if (c <= 0xFFFF) return ("" + (char) (0xE0 + ((c >> 12) & 0x0F)) + (char) (0x80 + ((c >> 6) & 0x3F)) + (char) (0x80 + (c & 0x3F)));
      return ("" + c);
    }
docs: Encodes a character to UTF8 (if necessary)