w32: Always use UTF-8 for localized texts

* configure.ac: Define GPG_ERR_ENABLE_GETTEXT_MACROS.
* src/version.c (do_subsystem_inits) [W32]: Switch gettext to UTF-8.
--

On Windows, applications using GpgME can now rely on localized texts
returned by GpgME, e.g. the texts for error codes, to be UTF-8 encoded.
In particular, this saves a useless and possibly lossy conversion to
native encoding and back to UTF-8. On other OSes, where we use the
system provided gettext, we assume that UTF-8 is used nowadays.

GnuPG-bug-id: 5960
This commit is contained in:
Ingo Klöcker 2023-04-04 12:11:15 +02:00
parent 34cc7daba1
commit d256ba7cc5
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
3 changed files with 9 additions and 0 deletions

3
NEWS
View File

@ -1,6 +1,9 @@
Noteworthy changes in version 1.20.0 (unreleased) Noteworthy changes in version 1.20.0 (unreleased)
------------------------------------------------- -------------------------------------------------
* On Windows, the gettext functions provided by gpgrt are switched into utf8
mode, so that all localized texts returned by GpgME or gpgrt, e.g. the
texts for error codes are now UTF-8 encoded.
* Interface changes relative to the 1.19.0 release: * Interface changes relative to the 1.19.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -922,6 +922,9 @@ AH_BOTTOM([
# define GPGME_GCC_A_PURE # define GPGME_GCC_A_PURE
#endif #endif
/* Under Windows we use the gettext code from gpgrt. */
#define GPG_ERR_ENABLE_GETTEXT_MACROS
/* Under WindowsCE we need gpg-error's strerror macro. */ /* Under WindowsCE we need gpg-error's strerror macro. */
#define GPG_ERR_ENABLE_ERRNO_MACROS 1 #define GPG_ERR_ENABLE_ERRNO_MACROS 1

View File

@ -72,6 +72,9 @@ do_subsystem_inits (void)
WSAStartup (0x202, &wsadat); WSAStartup (0x202, &wsadat);
} }
/* We want gpgrt's gettext to always output UTF-8. */
gettext_use_utf8 (1);
#endif #endif
_gpgme_debug_subsystem_init (); _gpgme_debug_subsystem_init ();