From 224290463c8e1dca64c82272d5a382930c483145 Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 8 Feb 2006 04:32:05 +0000 Subject: fixed locale encoding problem on win32. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@987 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 9 +++++++++ ChangeLog.ja | 9 +++++++++ libsylph/codeconv.c | 20 ++++++++++++++++++-- src/rfc2015.c | 5 ++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0983c289..c59869db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-02-08 + + * libsylph/codeconv.c: + conv_get_locale_charset() + conv_get_locale_charset_str(): use GLib API on Win32 (fixes wrong + encoding returned). + src/rfc2015.c: sig_status_full(): use g_locale_to_utf8() for locale + to UTF-8 conversion. + 2006-02-07 * src/mainwindow.c: made the help window of command line options diff --git a/ChangeLog.ja b/ChangeLog.ja index c33a93c7..461dfe88 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,12 @@ +2006-02-08 + + * libsylph/codeconv.c: + conv_get_locale_charset() + conv_get_locale_charset_str(): Win32 では GLib API を使用するように + した(誤ったエンコーディングが返るのを修正)。 + src/rfc2015.c: sig_status_full(): ロケールから UTF-8 への変換に + g_locale_to_utf8() を使用。 + 2006-02-07 * src/mainwindow.c: コマンドラインオプションのヘルプウィンドウを diff --git a/libsylph/codeconv.c b/libsylph/codeconv.c index 73bebb7f..59b5bd71 100644 --- a/libsylph/codeconv.c +++ b/libsylph/codeconv.c @@ -1,6 +1,6 @@ /* * LibSylph -- E-Mail client library - * Copyright (C) 1999-2005 Hiroyuki Yamamoto + * Copyright (C) 1999-2006 Hiroyuki Yamamoto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1841,7 +1841,9 @@ CharSet conv_get_locale_charset(void) static CharSet cur_charset = -1; const gchar *cur_locale; const gchar *p; +#ifndef G_OS_WIN32 gint i; +#endif if (cur_charset != -1) return cur_charset; @@ -1862,6 +1864,11 @@ CharSet conv_get_locale_charset(void) return cur_charset; } +#ifdef G_OS_WIN32 + cur_charset = conv_get_charset_from_str(conv_get_locale_charset_str()); + + return cur_charset; +#else for (i = 0; i < sizeof(locale_table) / sizeof(locale_table[0]); i++) { const gchar *p; @@ -1884,14 +1891,23 @@ CharSet conv_get_locale_charset(void) cur_charset = C_AUTO; return cur_charset; +#endif } const gchar *conv_get_locale_charset_str(void) { static const gchar *codeset = NULL; - if (!codeset) + if (!codeset) { +#ifdef G_OS_WIN32 + g_get_charset(&codeset); + if (!strcmp(codeset, CS_US_ASCII) || + !strcmp(codeset, CS_ANSI_X3_4_1968)) + codeset = CS_INTERNAL; +#else codeset = conv_get_charset_str(conv_get_locale_charset()); +#endif + } return codeset ? codeset : CS_INTERNAL; } diff --git a/src/rfc2015.c b/src/rfc2015.c index fc2ccfb7..8f1d975f 100644 --- a/src/rfc2015.c +++ b/src/rfc2015.c @@ -172,7 +172,10 @@ static gchar *sig_status_full(gpgme_ctx_t ctx, gpgme_verify_result_t result) ctime_val = localtime(&created); my_strftime(ctime_str, sizeof (ctime_str), "%c", ctime_val); - ctime_str_utf8 = conv_localetodisp(ctime_str, NULL); + ctime_str_utf8 = g_locale_to_utf8(ctime_str, -1, + NULL, NULL, NULL); + if (!ctime_str_utf8) + ctime_str_utf8 = g_strdup(ctime_str); g_string_sprintfa(str, _("Signature made at %s\n"), ctime_str_utf8); g_free(ctime_str_utf8); -- cgit v1.2.3