diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-08-29 02:12:09 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-09 18:22:21 +0200 |
commit | 90bad24f96deeaaa2255f0ad89ece21d5397b78b (patch) | |
tree | 4eb57e5412df5563de6f2b7e6df79787737ec519 | |
parent | 7c592561af3bbbad2eaf865247811ba2bd590c2e (diff) | |
download | sciteco-90bad24f96deeaaa2255f0ad89ece21d5397b78b.tar.gz |
allow Unicode characters in command line arguments (refs #5)
* the locale must be initialized very early before g_option_context_parse()
* will allow UTF-8 characters in the test suite
-rw-r--r-- | src/interface-curses/interface.c | 4 | ||||
-rw-r--r-- | src/main.c | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 89be588..443a903 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -24,7 +24,6 @@ #include <stdlib.h> #include <stdarg.h> #include <unistd.h> -#include <locale.h> #include <errno.h> #ifdef HAVE_WINDOWS_H @@ -679,9 +678,6 @@ teco_interface_init_interactive(GError **error) PDC_set_function_key(FUNCTION_KEY_SHUT_DOWN, KEY_CLOSE); #endif - /* for displaying UTF-8 characters properly */ - setlocale(LC_ALL, ""); - teco_interface_init_screen(); /* @@ -23,6 +23,7 @@ #include <string.h> #include <stdlib.h> #include <signal.h> +#include <locale.h> #include <glib.h> #include <glib/gprintf.h> @@ -306,6 +307,13 @@ main(int argc, char **argv) signal(SIGINT, teco_sigint_handler); signal(SIGTERM, teco_sigint_handler); + /* + * Important for Unicode handling in curses and glib. + * In particular, in order to accept Unicode characters + * in option strings. + */ + setlocale(LC_ALL, ""); + g_autofree gchar *mung_filename = teco_process_options(&argc, &argv); /* * All remaining arguments in argv are arguments |