[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e4e1e268c8e 2/2: Set a default locale on Android

From: Po Lu
Subject: master e4e1e268c8e 2/2: Set a default locale on Android
Date: Thu, 7 Dec 2023 01:05:54 -0500 (EST)

branch: master
commit e4e1e268c8e9f7de6fe5d4b05beb595a1781c02c
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Set a default locale on Android
    * doc/emacs/android.texi (Android Environment): Revise for
    * src/android.c (initEmacs): Set LANG to either en_US.utf8 or C,
    subject to whether the system is newer than Android
    5.0 (inclusive).
 doc/emacs/android.texi | 10 ++++++++++
 src/android.c          | 12 ++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/doc/emacs/android.texi b/doc/emacs/android.texi
index 915ba948b93..52912d045eb 100644
--- a/doc/emacs/android.texi
+++ b/doc/emacs/android.texi
@@ -409,6 +409,16 @@ Startup}) connect the Android system to another computer, 
and run:
 $ adb shell "settings put global settings_enable_monitor_phantom_procs false"
 @end example
+@cindex C locale settings, Android
+  Emacs does not respect the locale configured for user applications
+in the system, for the selection of locales available there does not
+match that supplied by the C library.  When Emacs starts on Android
+5.0 or newer, the @code{LANG} environment variable is set to
+@code{en_US.utf8}, which induces subprocesses linked against the
+Android C library to print output sensibly.  Earlier versions of
+Android do not implement locales at all, on account of which the
+variable is set to @code{C} instead.
 @cindex running emacs in the background, android
 @cindex emacs killed, android
 @cindex emacs in the background, android
diff --git a/src/android.c b/src/android.c
index 7ca5eab817c..51622f16230 100644
--- a/src/android.c
+++ b/src/android.c
@@ -1455,6 +1455,18 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject 
      the possibility of Java locating libemacs later.  */
   setenv ("EMACS_LD_LIBRARY_PATH", android_lib_dir, 1);
+  /* If the system is Android 5.0 or later, set LANG to en_US.utf8,
+     which is understood by the C library.  In other instances set it
+     to C, a meaningless value, for good measure.  */
+  if (emacs_service_object)
+    {
+      if (api_level >= 21)
+       setenv ("LANG", "en_US.utf8", 1);
+      else
+       setenv ("LANG", "C", 1);
+    }
   /* Make a reference to the Emacs service.  */
   if (emacs_service_object)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]