summaryrefslogtreecommitdiffstats
path: root/g10/passphrase.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2007-10-19 17:58:38 +0200
committerWerner Koch <wk@gnupg.org>2007-10-19 17:58:38 +0200
commitc12ce55b25685738bc1668df7b7bde87c4ba023c (patch)
treea863f6912c1d113edc361ee47d69e3135fe703b0 /g10/passphrase.c
parentEnhanced gpg-conect-agent scripting. (diff)
downloadgnupg2-c12ce55b25685738bc1668df7b7bde87c4ba023c.tar.xz
gnupg2-c12ce55b25685738bc1668df7b7bde87c4ba023c.zip
Factored utf8 switching code out to i18n.c.
Diffstat (limited to 'g10/passphrase.c')
-rw-r--r--g10/passphrase.c34
1 files changed, 6 insertions, 28 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c
index ad085486b..cf67b7f9f 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -257,9 +257,7 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid,
PKT_public_key *pk = xmalloc_clear( sizeof *pk );
byte fpr[MAX_FINGERPRINT_LEN];
int have_fpr = 0;
-#ifdef ENABLE_NLS
- char *orig_codeset = NULL;
-#endif
+ char *orig_codeset;
char *my_prompt;
char hexfprbuf[20*2+1];
const char *my_cacheid;
@@ -279,23 +277,7 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid,
pk = NULL; /* oops: no key for some reason */
}
-#ifdef ENABLE_NLS
- /* The Assuan agent protocol requires us to transmit utf-8 strings */
- orig_codeset = bind_textdomain_codeset (PACKAGE_GT, NULL);
-#ifdef HAVE_LANGINFO_CODESET
- if (!orig_codeset)
- orig_codeset = nl_langinfo (CODESET);
-#endif
- if (orig_codeset)
- { /* We only switch when we are able to restore the codeset later. */
- orig_codeset = xstrdup (orig_codeset);
- if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8"))
- {
- xfree (orig_codeset);
- orig_codeset = NULL;
- }
- }
-#endif
+ orig_codeset = i18n_switchto_utf8 ();
if (custom_description)
atext = native_to_utf8 (custom_description);
@@ -371,6 +353,9 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid,
xfree (my_prompt);
xfree (atext); atext = NULL;
+ i18n_switchback (orig_codeset);
+
+
if (!rc)
;
else if ( gpg_err_code (rc) == GPG_ERR_CANCELED )
@@ -392,14 +377,7 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid,
if (canceled)
*canceled = 1;
}
-
-#ifdef ENABLE_NLS
- if (orig_codeset)
- {
- bind_textdomain_codeset (PACKAGE_GT, orig_codeset);
- xfree (orig_codeset);
- }
-#endif
+
if (pk)
free_public_key( pk );
if (rc)