diff options
Diffstat (limited to 'src/emacs.c')
-rw-r--r-- | src/emacs.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/emacs.c b/src/emacs.c index 80bb70cedeb..1392209f585 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -95,6 +95,10 @@ extern void moncontrol (int mode); #include <locale.h> #endif +#if HAVE_WCHAR_H +# include <wchar.h> +#endif + #ifdef HAVE_SETRLIMIT #include <sys/time.h> #include <sys/resource.h> @@ -344,6 +348,19 @@ setlocale (int cat, char const *locale) } #endif +/* True if the current system locale uses UTF-8 encoding. */ +static bool +using_utf8 (void) +{ +#ifdef HAVE_WCHAR_H + wchar_t wc; + mbstate_t mbs = { 0 }; + return mbrtowc (&wc, "\xc4\x80", 2, &mbs) == 2 && wc == 0x100; +#else + return false; +#endif +} + /* Report a fatal error due to signal SIG, output a backtrace of at most BACKTRACE_LIMIT lines, and exit. */ @@ -924,6 +941,7 @@ main (int argc, char **argv) fixup_locale must wait until later, since it builds strings. */ if (do_initial_setlocale) setlocale (LC_ALL, ""); + text_quoting_flag = using_utf8 (); inhibit_window_system = 0; |