diff options
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/coding.c b/src/coding.c index 899f8fc7b4d..b7f4120dc8d 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -8494,7 +8494,7 @@ preferred_coding_system (void) | |||
| 8494 | return CODING_ID_NAME (id); | 8494 | return CODING_ID_NAME (id); |
| 8495 | } | 8495 | } |
| 8496 | 8496 | ||
| 8497 | #if defined (WINDOWSNT) || defined (CYGWIN) | 8497 | #if defined (WINDOWSNT) || defined (CYGWIN) || defined HAVE_ANDROID |
| 8498 | 8498 | ||
| 8499 | Lisp_Object | 8499 | Lisp_Object |
| 8500 | from_unicode (Lisp_Object str) | 8500 | from_unicode (Lisp_Object str) |
| @@ -8512,10 +8512,31 @@ from_unicode (Lisp_Object str) | |||
| 8512 | Lisp_Object | 8512 | Lisp_Object |
| 8513 | from_unicode_buffer (const wchar_t *wstr) | 8513 | from_unicode_buffer (const wchar_t *wstr) |
| 8514 | { | 8514 | { |
| 8515 | #if defined WINDOWSNT || defined CYGWIN | ||
| 8515 | /* We get one of the two final null bytes for free. */ | 8516 | /* We get one of the two final null bytes for free. */ |
| 8516 | ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr); | 8517 | ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr); |
| 8517 | AUTO_STRING_WITH_LEN (str, (char *) wstr, len); | 8518 | AUTO_STRING_WITH_LEN (str, (char *) wstr, len); |
| 8518 | return from_unicode (str); | 8519 | return from_unicode (str); |
| 8520 | #else | ||
| 8521 | /* This code is used only on Android, where little endian UTF-16 | ||
| 8522 | strings are extended to 32-bit wchar_t. */ | ||
| 8523 | |||
| 8524 | uint16_t *words; | ||
| 8525 | size_t length, i; | ||
| 8526 | |||
| 8527 | length = wcslen (wstr) + 1; | ||
| 8528 | |||
| 8529 | USE_SAFE_ALLOCA; | ||
| 8530 | SAFE_NALLOCA (words, sizeof *words, length); | ||
| 8531 | |||
| 8532 | for (i = 0; i < length - 1; ++i) | ||
| 8533 | words[i] = wstr[i]; | ||
| 8534 | |||
| 8535 | words[i] = '\0'; | ||
| 8536 | AUTO_STRING_WITH_LEN (str, (char *) words, | ||
| 8537 | (length - 1) * sizeof *words); | ||
| 8538 | return unbind_to (sa_count, from_unicode (str)); | ||
| 8539 | #endif | ||
| 8519 | } | 8540 | } |
| 8520 | 8541 | ||
| 8521 | wchar_t * | 8542 | wchar_t * |
| @@ -8535,7 +8556,7 @@ to_unicode (Lisp_Object str, Lisp_Object *buf) | |||
| 8535 | return WCSDATA (*buf); | 8556 | return WCSDATA (*buf); |
| 8536 | } | 8557 | } |
| 8537 | 8558 | ||
| 8538 | #endif /* WINDOWSNT || CYGWIN */ | 8559 | #endif /* WINDOWSNT || CYGWIN || HAVE_ANDROID */ |
| 8539 | 8560 | ||
| 8540 | 8561 | ||
| 8541 | /*** 8. Emacs Lisp library functions ***/ | 8562 | /*** 8. Emacs Lisp library functions ***/ |
| @@ -11745,7 +11766,7 @@ syms_of_coding (void) | |||
| 11745 | DEFSYM (Qutf_8_unix, "utf-8-unix"); | 11766 | DEFSYM (Qutf_8_unix, "utf-8-unix"); |
| 11746 | DEFSYM (Qutf_8_emacs, "utf-8-emacs"); | 11767 | DEFSYM (Qutf_8_emacs, "utf-8-emacs"); |
| 11747 | 11768 | ||
| 11748 | #if defined (WINDOWSNT) || defined (CYGWIN) | 11769 | #if defined (WINDOWSNT) || defined (CYGWIN) || defined HAVE_ANDROID |
| 11749 | /* No, not utf-16-le: that one has a BOM. */ | 11770 | /* No, not utf-16-le: that one has a BOM. */ |
| 11750 | DEFSYM (Qutf_16le, "utf-16le"); | 11771 | DEFSYM (Qutf_16le, "utf-16le"); |
| 11751 | #endif | 11772 | #endif |