From 7f36440d90964ffe809064365cb16033ba1dda69 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 2 Aug 2024 09:42:57 +0200 Subject: w32: Allow initialization of new threads to utf8 mode. * src/init.c (utf8_for_new_threads): New var. (_gpgrt_w32_utf8_for_new_threads): New func. (get_tls): Init the TLS utf8 flag from the new var. * src/w32-gettext.c (_gpg_w32_gettext_use_utf8): Implement new flag. -- GnuPG-bug-id: 7185 --- src/init.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/init.c') diff --git a/src/init.c b/src/init.c index c4b7e56..8a5e651 100644 --- a/src/init.c +++ b/src/init.c @@ -39,6 +39,8 @@ static int tls_index = TLS_OUT_OF_INDEXES; /* Index for the TLS functions. */ +static volatile int utf8_for_new_threads; + static char *get_locale_dir (void); static void drop_locale_dir (char *locale_dir); @@ -549,6 +551,14 @@ _gpgrt_internal_trace_end (void) ******** Below is only Windows code. **** *****************************************/ +/* This function can be called to force utf8 for new threads. */ +void +_gpgrt_w32_utf8_for_new_threads (void) +{ + utf8_for_new_threads = 1; +} + + static char * get_locale_dir (void) { @@ -645,7 +655,7 @@ get_tls (void) /* No way to continue - commit suicide. */ _gpgrt_abort (); } - tls->gt_use_utf8 = 0; + tls->gt_use_utf8 = utf8_for_new_threads; TlsSetValue (tls_index, tls); } @@ -677,7 +687,7 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved) tls = LocalAlloc (LPTR, sizeof *tls); if (!tls) return FALSE; - tls->gt_use_utf8 = 0; + tls->gt_use_utf8 = utf8_for_new_threads; TlsSetValue (tls_index, tls); if (reason == DLL_PROCESS_ATTACH) { -- cgit v1.2.3