{
Lisp_Object encoded;
jstring string;
+ size_t nchars;
+ jchar *characters;
+ USE_SAFE_ALLOCA;
- encoded = ENCODE_UTF_8 (text);
+ encoded = code_convert_string_norecord (text, Qutf_16le,
+ true);
+ nchars = (SBYTES (encoded) / sizeof (jchar));
- /* Note that Java expects this string to be in ``modified UTF
- encoding'', which is actually UTF-8, except with NUL encoded as a
- two-byte sequence. The only consequence of passing an actual
- UTF-8 string is that NUL bytes cannot be represented, which is
- not really of consequence. */
- string = (*android_java_env)->NewStringUTF (android_java_env,
- SSDATA (encoded));
+ /* Encode the string as UTF-16 prior to creating the string.
+ Copy the string to a separate buffer in order to preserve
+ alignment. */
+
+ characters = SAFE_ALLOCA (SBYTES (encoded));
+ memcpy (characters, SDATA (encoded), SBYTES (encoded));
+
+ /* Create the string. */
+ string
+ = (*android_java_env)->NewString (android_java_env,
+ characters, nchars);
android_exception_check ();
+ SAFE_FREE ();
return string;
}
-/* Do the same, except TEXT is constant string data. */
+/* Do the same, except TEXT is constant string data in ASCII or
+ UTF-8 containing no characters outside the Basic Multilingual
+ Plane. */
jstring
android_build_jstring (const char *text)
{
jstring string;
+ /* Note that Java expects this string to be in ``modified UTF
+ encoding'', which is actually UTF-8, except with NUL
+ encoded as a two-byte sequence, and surrogate pairs encoded
+ in the three-byte extended encoding. The only consequence
+ of passing an actual UTF-8 string is that NUL bytes and
+ characters requiring surrogate pairs cannot be represented,
+ which is not really of consequence. */
+
string = (*android_java_env)->NewStringUTF (android_java_env,
text);
android_exception_check ();
FIND_METHOD_STATIC (create_context_menu, "createContextMenu",
"(Ljava/lang/String;)Lorg/gnu/emacs/EmacsContextMenu;");
- FIND_METHOD (add_item, "addItem", "(ILjava/lang/String;ZZZ)V");
+ FIND_METHOD (add_item, "addItem", "(ILjava/lang/String;ZZZ"
+ "Ljava/lang/String;)V");
FIND_METHOD (add_submenu, "addSubmenu", "(Ljava/lang/String;"
"Ljava/lang/String;Ljava/lang/String;)"
"Lorg/gnu/emacs/EmacsContextMenu;");
title_string = (!NILP (item_name)
? android_build_string (item_name)
: NULL);
+ help_string = NULL;
+
+ /* Menu items can have tool tips on Android 26 and
+ later. In this case, set it to the help string. */
+
+ if (android_get_current_api_level () >= 26
+ && STRINGP (help))
+ help_string = android_build_string (help);
/* Determine whether or not to display a check box. */
title_string,
(jboolean) !NILP (enable),
(jboolean) checkmark,
- (jboolean) !NILP (selected));
+ (jboolean) !NILP (selected),
+ help_string);
android_exception_check ();
if (title_string)
ANDROID_DELETE_LOCAL_REF (title_string);
+
+ if (help_string)
+ ANDROID_DELETE_LOCAL_REF (help_string);
}
i += MENU_ITEMS_ITEM_LENGTH;
/* Swap values from TrueType to system byte order. */
static void
-_sfnt_swap16 (uint16_t *value)
+sfnt_swap16_1 (uint16_t *value)
{
#ifndef WORDS_BIGENDIAN
*value = bswap_16 (*value);
}
static void
-_sfnt_swap32 (uint32_t *value)
+sfnt_swap32_1 (uint32_t *value)
{
#ifndef WORDS_BIGENDIAN
*value = bswap_32 (*value);
#endif
}
-#define sfnt_swap16(what) (_sfnt_swap16 ((uint16_t *) (what)))
-#define sfnt_swap32(what) (_sfnt_swap32 ((uint32_t *) (what)))
+#define sfnt_swap16(what) (sfnt_swap16_1 ((uint16_t *) (what)))
+#define sfnt_swap32(what) (sfnt_swap32_1 ((uint32_t *) (what)))
/* Read the table directory from the file FD. FD must currently be at
the start of the file (or an offset defined in the TTC header, if