2005-02-01 [paul] 1.0.0cvs24.2
authorPaul Mangan <paul@claws-mail.org>
Tue, 1 Feb 2005 08:58:33 +0000 (08:58 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 1 Feb 2005 08:58:33 +0000 (08:58 +0000)
* src/addrbook.c
* src/addrindex.c
* src/alertpanel.h
* src/codeconv.c
* src/codeconv.h
* src/compose.c
* src/export.c
* src/folder_item_prefs.c
* src/html.c
* src/imap.c
* src/import.c
* src/jpilot.c
* src/mainwindow.c
* src/matcher_parser_lex.l
* src/messageview.c
* src/mh.c
* src/prefs_account.c
* src/prefs_actions.c
* src/prefs_common.c
* src/prefs_gtk.c
* src/prefs_gtk.h
* src/prefs_themes.c
* src/procheader.c
* src/procmime.c
* src/sourcewindow.c
* src/statusbar.c
* src/summaryview.c
* src/textview.c
* src/toolbar.c
* src/unmime.c
* src/common/template.c
* src/common/utils.c
* src/common/xml.c
* src/common/xml.h
* src/gtk/gtkaspell.c
* src/plugins/clamav/clamav_plugin.c
* src/plugins/dillo_viewer/dillo_prefs.c
* src/plugins/image_viewer/viewerprefs.c
* src/plugins/pgpmime/passphrase.c
* src/plugins/pgpmime/prefs_gpg.c
* src/plugins/pgpmime/select-keys.c
* src/plugins/spamassassin/spamassassin.c
second part of initial sync with main-gtk2
(more to follow)

45 files changed:
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/addrbook.c
src/addrindex.c
src/alertpanel.h
src/codeconv.c
src/codeconv.h
src/common/template.c
src/common/utils.c
src/common/xml.c
src/common/xml.h
src/compose.c
src/export.c
src/folder_item_prefs.c
src/gtk/gtkaspell.c
src/html.c
src/imap.c
src/import.c
src/jpilot.c
src/mainwindow.c
src/matcher_parser_lex.l
src/messageview.c
src/mh.c
src/plugins/clamav/clamav_plugin.c
src/plugins/dillo_viewer/dillo_prefs.c
src/plugins/image_viewer/viewerprefs.c
src/plugins/pgpmime/passphrase.c
src/plugins/pgpmime/prefs_gpg.c
src/plugins/pgpmime/select-keys.c
src/plugins/spamassassin/spamassassin.c
src/prefs_account.c
src/prefs_actions.c
src/prefs_common.c
src/prefs_gtk.c
src/prefs_gtk.h
src/prefs_themes.c
src/procheader.c
src/procmime.c
src/sourcewindow.c
src/statusbar.c
src/summaryview.c
src/textview.c
src/toolbar.c
src/unmime.c

index d0c0190..6516691 100644 (file)
@@ -1,3 +1,50 @@
+2005-02-01 [paul]      1.0.0cvs24.2
+
+       * src/addrbook.c
+       * src/addrindex.c
+       * src/alertpanel.h
+       * src/codeconv.c
+       * src/codeconv.h
+       * src/compose.c
+       * src/export.c
+       * src/folder_item_prefs.c
+       * src/html.c
+       * src/imap.c
+       * src/import.c
+       * src/jpilot.c
+       * src/mainwindow.c
+       * src/matcher_parser_lex.l
+       * src/messageview.c
+       * src/mh.c
+       * src/prefs_account.c
+       * src/prefs_actions.c
+       * src/prefs_common.c
+       * src/prefs_gtk.c
+       * src/prefs_gtk.h
+       * src/prefs_themes.c
+       * src/procheader.c
+       * src/procmime.c
+       * src/sourcewindow.c
+       * src/statusbar.c
+       * src/summaryview.c
+       * src/textview.c
+       * src/toolbar.c
+       * src/unmime.c
+       * src/common/template.c
+       * src/common/utils.c
+       * src/common/xml.c
+       * src/common/xml.h
+       * src/gtk/gtkaspell.c
+       * src/plugins/clamav/clamav_plugin.c
+       * src/plugins/dillo_viewer/dillo_prefs.c
+       * src/plugins/image_viewer/viewerprefs.c
+       * src/plugins/pgpmime/passphrase.c
+       * src/plugins/pgpmime/prefs_gpg.c
+       * src/plugins/pgpmime/select-keys.c
+       * src/plugins/spamassassin/spamassassin.c
+               second part of initial sync with main-gtk2
+               (more to follow)
+
 2005-01-31 [colin]     1.0.0cvs24.1
 
        * src/compose.c
index 012856d..c8df146 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.207.2.27 -r 1.207.2.28 src/folderview.c; ) > 1.0.0cvs23.1.patchset
 ( cvs diff -u -r 1.61.2.20 -r 1.61.2.21 src/account.c; cvs diff -u -r 1.12.2.18 -r 1.12.2.19 src/action.c; cvs diff -u -r 1.9.2.2 -r 1.9.2.3 src/addressadd.c; cvs diff -u -r 1.60.2.13 -r 1.60.2.14 src/addressbook.c; cvs diff -u -r 1.17.2.9 -r 1.17.2.10 src/alertpanel.c; cvs diff -u -r 1.382.2.90 -r 1.382.2.91 src/compose.c; cvs diff -u -r 1.14.2.4 -r 1.14.2.5 src/editaddress.c; cvs diff -u -r 1.5.12.1 -r 1.5.12.2 src/editbook.c; cvs diff -u -r 1.11.2.4 -r 1.11.2.5 src/editgroup.c; cvs diff -u -r 1.5.12.1 -r 1.5.12.2 src/editjpilot.c; cvs diff -u -r 1.8.2.2 -r 1.8.2.3 src/editldap.c; cvs diff -u -r 1.10.2.2 -r 1.10.2.3 src/editldap_basedn.c; cvs diff -u -r 1.5.12.1 -r 1.5.12.2 src/editvcard.c; cvs diff -u -r 1.8.2.4 -r 1.8.2.5 src/export.c; cvs diff -u -r 1.26.2.10 -r 1.26.2.11 src/foldersel.c; cvs diff -u -r 1.14.2.6 -r 1.14.2.7 src/grouplistdialog.c; cvs diff -u -r 1.13.2.5 -r 1.13.2.6 src/import.c; cvs diff -u -r 1.14.2.2 -r 1.14.2.3 src/importldif.c; cvs diff -u -r 1.149.2.19 -r 1.149.2.20 src/inc.c; cvs diff -u -r 1.115.2.26 -r 1.115.2.27 src/main.c; cvs diff -u -r 1.274.2.28 -r 1.274.2.29 src/mainwindow.c; cvs diff -u -r 1.3.12.6 -r 1.3.12.7 src/message_search.c; cvs diff -u -r 1.94.2.39 -r 1.94.2.40 src/messageview.c; cvs diff -u -r 1.83.2.26 -r 1.83.2.27 src/mimeview.c; cvs diff -u -r 1.60.2.10 -r 1.60.2.11 src/prefs_actions.c; cvs diff -u -r 1.204.2.28 -r 1.204.2.29 src/prefs_common.c; cvs diff -u -r 1.103.2.11 -r 1.103.2.12 src/prefs_common.h; cvs diff -u -r 1.16.2.6 -r 1.16.2.7 src/prefs_customheader.c; cvs diff -u -r 1.16.2.6 -r 1.16.2.7 src/prefs_display_header.c; cvs diff -u -r 1.59.2.13 -r 1.59.2.14 src/prefs_filtering.c; cvs diff -u -r 1.1.4.10 -r 1.1.4.11 src/prefs_filtering_action.c; cvs diff -u -r 1.10.2.9 -r 1.10.2.10 src/prefs_gtk.c; cvs diff -u -r 1.43.2.15 -r 1.43.2.16 src/prefs_matcher.c; cvs diff -u -r 1.10.2.4 -r 1.10.2.5 src/prefs_summary_column.c; cvs diff -u -r 1.12.2.6 -r 1.12.2.7 src/prefs_template.c; cvs diff -u -r 1.9.2.8 -r 1.9.2.9 src/sourcewindow.c; cvs diff -u -r 1.15.2.12 -r 1.15.2.13 src/summary_search.c; cvs diff -u -r 1.395.2.48 -r 1.395.2.49 src/summaryview.c; cvs diff -u -r 1.96.2.39 -r 1.96.2.40 src/textview.c; cvs diff -u -r 1.4.2.5 -r 1.4.2.6 src/gtk/about.c; cvs diff -u -r 1.5.2.6 -r 1.5.2.7 src/gtk/description_window.c; cvs diff -u -r 1.1.4.3 -r 1.1.4.4 src/gtk/gtkshruler.c; cvs diff -u -r 1.5.2.7 -r 1.5.2.8 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.6 -r 1.4.2.7 src/gtk/gtkutils.h; cvs diff -u -r 1.2.2.3 -r 1.2.2.4 src/gtk/inputdialog.c; cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/gtk/logwindow.c; cvs diff -u -r 1.12.2.14 -r 1.12.2.15 src/gtk/prefswindow.c; cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/gtk/progressdialog.c; cvs diff -u -r 1.1.4.3 -r 1.1.4.4 src/gtk/progressdialog.h; ) > 1.0.0cvs23.2.patchset
 ( cvs diff -u -r 1.382.2.91 -r 1.382.2.92 src/compose.c; ) > 1.0.0cvs24.1.patchset
+( cvs diff -u -r 1.22.2.2 -r 1.22.2.3 src/addrbook.c; cvs diff -u -r 1.28.2.4 -r 1.28.2.5 src/addrindex.c; cvs diff -u -r 1.5.2.2 -r 1.5.2.3 src/alertpanel.h; cvs diff -u -r 1.65.2.20 -r 1.65.2.21 src/codeconv.c; cvs diff -u -r 1.15.2.3 -r 1.15.2.4 src/codeconv.h; cvs diff -u -r 1.382.2.92 -r 1.382.2.93 src/compose.c; cvs diff -u -r 1.8.2.5 -r 1.8.2.6 src/export.c; cvs diff -u -r 1.2.2.4 -r 1.2.2.5 src/folder_item_prefs.c; cvs diff -u -r 1.12.2.5 -r 1.12.2.6 src/html.c; cvs diff -u -r 1.179.2.14 -r 1.179.2.15 src/imap.c; cvs diff -u -r 1.13.2.6 -r 1.13.2.7 src/import.c; cvs diff -u -r 1.18.2.5 -r 1.18.2.6 src/jpilot.c; cvs diff -u -r 1.274.2.29 -r 1.274.2.30 src/mainwindow.c; cvs diff -u -r 1.16.2.2 -r 1.16.2.3 src/matcher_parser_lex.l; cvs diff -u -r 1.94.2.40 -r 1.94.2.41 src/messageview.c; cvs diff -u -r 1.79.2.6 -r 1.79.2.7 src/mh.c; cvs diff -u -r 1.105.2.15 -r 1.105.2.16 src/prefs_account.c; cvs diff -u -r 1.60.2.11 -r 1.60.2.12 src/prefs_actions.c; cvs diff -u -r 1.204.2.29 -r 1.204.2.30 src/prefs_common.c; cvs diff -u -r 1.10.2.10 -r 1.10.2.11 src/prefs_gtk.c; cvs diff -u -r 1.5.2.2 -r 1.5.2.3 src/prefs_gtk.h; cvs diff -u -r 1.3.2.15 -r 1.3.2.16 src/prefs_themes.c; cvs diff -u -r 1.47.2.13 -r 1.47.2.14 src/procheader.c; cvs diff -u -r 1.49.2.30 -r 1.49.2.31 src/procmime.c; cvs diff -u -r 1.9.2.9 -r 1.9.2.10 src/sourcewindow.c; cvs diff -u -r 1.5.2.1 -r 1.5.2.2 src/statusbar.c; cvs diff -u -r 1.395.2.49 -r 1.395.2.50 src/summaryview.c; cvs diff -u -r 1.96.2.40 -r 1.96.2.41 src/textview.c; cvs diff -u -r 1.43.2.13 -r 1.43.2.14 src/toolbar.c; cvs diff -u -r 1.8.2.2 -r 1.8.2.3 src/unmime.c; cvs diff -u -r 1.2.4.3 -r 1.2.4.4 src/common/template.c; cvs diff -u -r 1.36.2.21 -r 1.36.2.22 src/common/utils.c; cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/common/xml.c; cvs diff -u -r 1.1.4.3 -r 1.1.4.4 src/common/xml.h; cvs diff -u -r 1.9.2.8 -r 1.9.2.9 src/gtk/gtkaspell.c; cvs diff -u -r 1.13.2.4 -r 1.13.2.5 src/plugins/clamav/clamav_plugin.c; cvs diff -u -r 1.5.2.3 -r 1.5.2.4 src/plugins/dillo_viewer/dillo_prefs.c; cvs diff -u -r 1.5.2.3 -r 1.5.2.4 src/plugins/image_viewer/viewerprefs.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/pgpmime/passphrase.c; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/pgpmime/prefs_gpg.c; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/pgpmime/select-keys.c; cvs diff -u -r 1.18.2.4 -r 1.18.2.5 src/plugins/spamassassin/spamassassin.c; ) > 1.0.0cvs24.2.patchset
index 658c34f..ba56314 100644 (file)
@@ -13,7 +13,7 @@ INTERFACE_AGE=0
 BINARY_AGE=0
 EXTRA_VERSION=24
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.1
+EXTRA_GTK2_VERSION=.2
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
index 7235b49..b6111be 100644 (file)
@@ -1268,8 +1268,7 @@ gint addrbook_write_to(AddressBookFile *book, gchar *newFile)
        g_free(fileSpec);
        if (pfile) {
                fp = pfile->fp;
-               fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n",
-                       conv_get_current_charset_str());
+               fprintf( fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL );
 #endif
                addrbook_write_elem_s(fp, 0, AB_ELTAG_ADDRESS_BOOK);
                addrbook_write_attr(fp, AB_ATTAG_NAME,
index 3f26fb6..2586fc9 100644 (file)
@@ -1722,8 +1722,7 @@ gint addrindex_write_to( AddressIndex *addrIndex, const gchar *newFile ) {
        g_free( fileSpec );
        if( pfile ) {
                fp = pfile->fp;
-               fprintf( fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n",
-                               conv_get_current_charset_str() );
+               fprintf( fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL );
 #endif
                addrindex_write_elem_s( fp, 0, TAG_ADDRESS_INDEX );
                fputs( ">\n", fp );
index 25a2667..5c15532 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,6 @@
 #define __ALERTPANEL_H__
 
 #include <glib.h>
-#include <gtk/gtkwindow.h>
 
 typedef enum
 {
index c8a960d..4a295d6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,6 +31,8 @@
 #  include <locale.h>
 #endif
 
+#include <iconv.h>
+
 #include "intl.h"
 #include "codeconv.h"
 #include "unmime.h"
@@ -100,7 +102,31 @@ typedef enum
                state = JIS_AUXKANJI;   \
        }
 
-void conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_jistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_sjistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_euctoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_utf8toeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_utf8tojis(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_unreadable_eucjp(gchar *str);
+static void conv_unreadable_8bit(gchar *str);
+static void conv_unreadable_latin(gchar *str);
+
+static void conv_jistodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_sjistodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_euctodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+static void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf);
+
+static void conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        const guchar *in = inbuf;
        guchar *out = outbuf;
@@ -235,7 +261,7 @@ static gint conv_jis_hantozen(guchar *outbuf, guchar jis_code, guchar sound_sym)
        return 1;
 }
 
-void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        const guchar *in = inbuf;
        guchar *out = outbuf;
@@ -323,7 +349,7 @@ void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf)
        *out = '\0';
 }
 
-void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        const guchar *in = inbuf;
        guchar *out = outbuf;
@@ -369,40 +395,71 @@ void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
        *out = '\0';
 }
 
-void conv_anytoeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_jistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       switch (conv_guess_ja_encoding(inbuf)) {
-       case C_ISO_2022_JP:
-               conv_jistoeuc(outbuf, outlen, inbuf);
-               break;
-       case C_SHIFT_JIS:
-               conv_sjistoeuc(outbuf, outlen, inbuf);
-               break;
-       default:
+       gchar *eucstr;
+
+       Xalloca(eucstr, outlen, return);
+
+       conv_jistoeuc(eucstr, outlen, inbuf);
+       conv_euctoutf8(outbuf, outlen, eucstr);
+}
+
+static void conv_sjistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
+{
+       gchar *tmpstr;
+
+       tmpstr = conv_iconv_strdup(inbuf, CS_SHIFT_JIS, CS_UTF_8);
+       if (tmpstr) {
+               strncpy2(outbuf, tmpstr, outlen);
+               g_free(tmpstr);
+       } else
                strncpy2(outbuf, inbuf, outlen);
-               break;
-       }
 }
 
-void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_euctoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       gchar *tmpstr = NULL;
+       static iconv_t cd = (iconv_t)-1;
+       static gboolean iconv_ok = TRUE;
+       gchar *tmpstr;
+
+       if (cd == (iconv_t)-1) {
+               if (!iconv_ok) {
+                       strncpy2(outbuf, inbuf, outlen);
+                       return;
+               }
+               cd = iconv_open(CS_UTF_8, CS_EUC_JP_MS);
+               if (cd == (iconv_t)-1) {
+                       cd = iconv_open(CS_UTF_8, CS_EUC_JP);
+                       if (cd == (iconv_t)-1) {
+                               g_warning("conv_euctoutf8(): %s\n",
+                                         g_strerror(errno));
+                               iconv_ok = FALSE;
+                               strncpy2(outbuf, inbuf, outlen);
+                               return;
+                       }
+               }
+       }
 
-       switch (conv_guess_ja_encoding(inbuf)) {
-       case C_ISO_2022_JP:
-               tmpstr = conv_codeset_strdup(inbuf, CS_ISO_2022_JP, CS_UTF_8);
+       tmpstr = conv_iconv_strdup_with_cd(inbuf, cd);
+       if (tmpstr) {
                strncpy2(outbuf, tmpstr, outlen);
                g_free(tmpstr);
+       } else
+               strncpy2(outbuf, inbuf, outlen);
+}
+
+static void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
+{
+       switch (conv_guess_ja_encoding(inbuf)) {
+       case C_ISO_2022_JP:
+               conv_jistoutf8(outbuf, outlen, inbuf);
                break;
        case C_SHIFT_JIS:
-               tmpstr = conv_codeset_strdup(inbuf, CS_SHIFT_JIS, CS_UTF_8);
-               strncpy2(outbuf, tmpstr, outlen);
-               g_free(tmpstr);
+               conv_sjistoutf8(outbuf, outlen, inbuf);
                break;
        case C_EUC_JP:
-               tmpstr = conv_codeset_strdup(inbuf, CS_EUC_JP, CS_UTF_8);
-               strncpy2(outbuf, tmpstr, outlen);
-               g_free(tmpstr);
+               conv_euctoutf8(outbuf, outlen, inbuf);
                break;
        default:
                strncpy2(outbuf, inbuf, outlen);
@@ -410,16 +467,46 @@ void conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
        }
 }
 
-void conv_anytojis(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_utf8toeuc(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       switch (conv_guess_ja_encoding(inbuf)) {
-       case C_EUC_JP:
-               conv_euctojis(outbuf, outlen, inbuf);
-               break;
-       default:
-               strncpy2(outbuf, inbuf, outlen);
-               break;
+       static iconv_t cd = (iconv_t)-1;
+       static gboolean iconv_ok = TRUE;
+       gchar *tmpstr;
+
+       if (cd == (iconv_t)-1) {
+               if (!iconv_ok) {
+                       strncpy2(outbuf, inbuf, outlen);
+                       return;
+               }
+               cd = iconv_open(CS_EUC_JP_MS, CS_UTF_8);
+               if (cd == (iconv_t)-1) {
+                       cd = iconv_open(CS_EUC_JP, CS_UTF_8);
+                       if (cd == (iconv_t)-1) {
+                               g_warning("conv_utf8toeuc(): %s\n",
+                                         g_strerror(errno));
+                               iconv_ok = FALSE;
+                               strncpy2(outbuf, inbuf, outlen);
+                               return;
+                       }
+               }
        }
+
+       tmpstr = conv_iconv_strdup_with_cd(inbuf, cd);
+       if (tmpstr) {
+               strncpy2(outbuf, tmpstr, outlen);
+               g_free(tmpstr);
+       } else
+               strncpy2(outbuf, inbuf, outlen);
+}
+
+static void conv_utf8tojis(gchar *outbuf, gint outlen, const gchar *inbuf)
+{
+       gchar *eucstr;
+
+       Xalloca(eucstr, outlen, return);
+
+       conv_utf8toeuc(eucstr, outlen, inbuf);
+       conv_euctojis(outbuf, outlen, eucstr);
 }
 
 static gchar valid_eucjp_tbl[][96] = {
@@ -504,7 +591,7 @@ static gboolean isprintableeuckanji(guchar c1, guchar c2)
        return TRUE;
 }
 
-void conv_unreadable_eucjp(gchar *str)
+static void conv_unreadable_eucjp(gchar *str)
 {
        register guchar *p = str;
 
@@ -547,7 +634,7 @@ void conv_unreadable_eucjp(gchar *str)
        }
 }
 
-void conv_unreadable_8bit(gchar *str)
+static void conv_unreadable_8bit(gchar *str)
 {
        register guchar *p = str;
 
@@ -560,7 +647,7 @@ void conv_unreadable_8bit(gchar *str)
        }
 }
 
-void conv_unreadable_latin(gchar *str)
+static void conv_unreadable_latin(gchar *str)
 {
        register guchar *p = str;
 
@@ -574,53 +661,6 @@ void conv_unreadable_latin(gchar *str)
        }
 }
 
-void conv_unreadable_utf8(gchar *str)
-{
-       register guchar *p = str;
-
-       while (*p != '\0') {
-               /* convert CR+LF -> LF */
-
-               if (*p == '\r' && *(p + 1) == '\n')
-                       memmove(p, p + 1, strlen(p));
-               else if (((*p & 0xff) >= 0x7f) 
-                        || *p == 0xfc)
-                       *p = SUBST_CHAR;
-               p++;
-       }
-}
-
-void conv_unreadable_locale(gchar *str)
-{
-       switch (conv_get_current_charset()) {
-       case C_US_ASCII:
-       case C_ISO_8859_1:
-       case C_ISO_8859_2:
-       case C_ISO_8859_3:
-       case C_ISO_8859_4:
-       case C_ISO_8859_5:
-       case C_ISO_8859_6:
-       case C_ISO_8859_7:
-       case C_ISO_8859_8:
-       case C_ISO_8859_9:
-       case C_ISO_8859_10:
-       case C_ISO_8859_11:
-       case C_ISO_8859_13:
-       case C_ISO_8859_14:
-       case C_ISO_8859_15:
-               conv_unreadable_latin(str);
-               break;
-       case C_EUC_JP:
-               conv_unreadable_eucjp(str);
-               break;
-       case C_UTF_8:
-               conv_unreadable_utf8(str);
-               break;
-       default:
-               break;
-       }
-}
-
 #define NCV    '\0'
 
 void conv_mb_alnum(gchar *str)
@@ -729,63 +769,63 @@ CharSet conv_guess_ja_encoding(const gchar *str)
        return guessed;
 }
 
-void conv_jistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_jistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       conv_jistoeuc(outbuf, outlen, inbuf);
-       conv_unreadable_eucjp(outbuf);
+       conv_jistoutf8(outbuf, outlen, inbuf);
 }
 
-void conv_sjistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_sjistodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       conv_sjistoeuc(outbuf, outlen, inbuf);
-       conv_unreadable_eucjp(outbuf);
+       conv_sjistoutf8(outbuf, outlen, inbuf);
 }
 
-void conv_euctodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_euctodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       strncpy2(outbuf, inbuf, outlen);
-       conv_unreadable_eucjp(outbuf);
+       conv_euctoutf8(outbuf, outlen, inbuf);
 }
 
-void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+void conv_utf8todisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       conv_anytoutf8(outbuf, outlen, inbuf);
+       strncpy2(outbuf, inbuf, outlen);
 }
 
-#warning FIXME_GTK2
-void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       strncpy2(outbuf, inbuf, outlen);
-       conv_unreadable_8bit(outbuf);
+       conv_anytoutf8(outbuf, outlen, inbuf);
 }
 
-#warning FIXME_GTK2
-void conv_latintodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        strncpy2(outbuf, inbuf, outlen);
-       conv_unreadable_latin(outbuf);
+       conv_unreadable_8bit(outbuf);
 }
 
-#warning FIXME_GTK2
 void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
-       strncpy2(outbuf, inbuf, outlen);
-       conv_unreadable_locale(outbuf);
+       gchar *tmpstr;
+
+       tmpstr = conv_iconv_strdup(inbuf, conv_get_locale_charset_str(),
+                                  CS_INTERNAL);
+       if (tmpstr) {
+               strncpy2(outbuf, tmpstr, outlen);
+               g_free(tmpstr);
+       } else
+               strncpy2(outbuf, inbuf, outlen);
 }
 
-void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
+static void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        strncpy2(outbuf, inbuf, outlen);
 }
 
-CodeConverter *conv_code_converter_new(const gchar *charset)
+CodeConverter *conv_code_converter_new(const gchar *src_charset)
 {
        CodeConverter *conv;
 
        conv = g_new0(CodeConverter, 1);
-       conv->code_conv_func = conv_get_code_conv_func(charset, CS_UTF_8);
-       conv->charset_str = g_strdup(charset);
-       conv->charset = conv_get_charset_from_str(charset);
+       conv->code_conv_func = conv_get_code_conv_func(src_charset, NULL);
+       conv->charset_str = g_strdup(src_charset);
+       conv->charset = conv_get_charset_from_str(src_charset);
 
        return conv;
 }
@@ -804,7 +844,7 @@ gint conv_convert(CodeConverter *conv, gchar *outbuf, gint outlen,
        else {
                gchar *str;
 
-               str = conv_iconv_strdup(inbuf, conv->charset_str, CS_UTF_8);
+               str = conv_iconv_strdup(inbuf, conv->charset_str, NULL);
                if (!str)
                        return -1;
                else {
@@ -844,7 +884,7 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
        CharSet dest_charset;
 
        if (!src_charset_str)
-               src_charset = conv_get_current_charset();
+               src_charset = conv_get_locale_charset();
        else
                src_charset = conv_get_charset_from_str(src_charset_str);
 
@@ -860,25 +900,9 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
 
        if (dest_charset == C_US_ASCII)
                return conv_ustodisp;
-       else if (dest_charset == C_UTF_8 ||
-                (dest_charset == C_AUTO &&
-                 conv_get_current_charset() == C_UTF_8))
-               return conv_noconv;
 
        switch (src_charset) {
-       case C_ISO_2022_JP:
-       case C_ISO_2022_JP_2:
-       case C_ISO_2022_JP_3:
-               if (dest_charset == C_AUTO &&
-                   conv_get_current_charset() == C_EUC_JP)
-                       code_conv = conv_jistodisp;
-               else if (dest_charset == C_EUC_JP)
-                       code_conv = conv_jistoeuc;
-               break;
        case C_US_ASCII:
-               if (dest_charset == C_AUTO)
-                       code_conv = conv_ustodisp;
-               break;
        case C_ISO_8859_1:
        case C_ISO_8859_2:
        case C_ISO_8859_3:
@@ -893,26 +917,42 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
        case C_ISO_8859_13:
        case C_ISO_8859_14:
        case C_ISO_8859_15:
-               if (dest_charset == C_AUTO &&
-                   (conv_get_current_charset() == src_charset ||
-                    MB_CUR_MAX > 1))
-                       code_conv = conv_latintodisp;
+               break;
+       case C_ISO_2022_JP:
+       case C_ISO_2022_JP_2:
+       case C_ISO_2022_JP_3:
+               if (dest_charset == C_AUTO)
+                       code_conv = conv_jistodisp;
+               else if (dest_charset == C_EUC_JP)
+                       code_conv = conv_jistoeuc;
+               else if (dest_charset == C_UTF_8)
+                       code_conv = conv_jistoutf8;
                break;
        case C_SHIFT_JIS:
-               if (dest_charset == C_AUTO &&
-                   conv_get_current_charset() == C_EUC_JP)
+               if (dest_charset == C_AUTO)
                        code_conv = conv_sjistodisp;
                else if (dest_charset == C_EUC_JP)
                        code_conv = conv_sjistoeuc;
+               else if (dest_charset == C_UTF_8)
+                       code_conv = conv_sjistoutf8;
                break;
        case C_EUC_JP:
-               if (dest_charset == C_AUTO &&
-                   conv_get_current_charset() == C_EUC_JP)
+               if (dest_charset == C_AUTO)
                        code_conv = conv_euctodisp;
                else if (dest_charset == C_ISO_2022_JP   ||
                         dest_charset == C_ISO_2022_JP_2 ||
                         dest_charset == C_ISO_2022_JP_3)
                        code_conv = conv_euctojis;
+               else if (dest_charset == C_UTF_8)
+                       code_conv = conv_euctoutf8;
+               break;
+       case C_UTF_8:
+               if (dest_charset == C_EUC_JP)
+                       code_conv = conv_utf8toeuc;
+               else if (dest_charset == C_ISO_2022_JP   ||
+                        dest_charset == C_ISO_2022_JP_2 ||
+                        dest_charset == C_ISO_2022_JP_3)
+                       code_conv = conv_utf8tojis;
                break;
        default:
                break;
@@ -922,37 +962,104 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
 }
 
 gchar *conv_iconv_strdup(const gchar *inbuf,
-                        const gchar *isrc_code, const gchar *idest_code)
+                        const gchar *src_code, const gchar *dest_code)
 {
-       /* presumably GLib 2's function handles the conversion details,
-        * whether iconv is sitting below, or something else */
+       iconv_t cd;
        gchar *outbuf;
-       gsize read_len, written_len;
-       gchar *src_code = (char *)conv_get_outgoing_charset_str();
-       gchar *dest_code = (char *)conv_get_current_charset_str();
-       
-       if (isrc_code)
-               src_code = (char *)isrc_code;
-       if (idest_code)
-               dest_code = (char *)idest_code;
 
-       /* don't convert if current codeset is US-ASCII */
-       if (!g_ascii_strcasecmp(dest_code, CS_US_ASCII))
-               return g_strdup(inbuf);
+       if (!src_code)
+               src_code = conv_get_outgoing_charset_str();
+       if (!dest_code)
+               dest_code = CS_INTERNAL;
 
        /* don't convert if src and dest codeset are identical */
-       if (!g_ascii_strcasecmp(src_code, dest_code))
+       if (!strcasecmp(src_code, dest_code))
+               return g_strdup(inbuf);
+
+       /* don't convert if current codeset is US-ASCII */
+       if (!strcasecmp(dest_code, CS_US_ASCII))
                return g_strdup(inbuf);
 
-       /* FIXME: unchecked inbuf? Can't see at this level. */
-       outbuf = g_convert(inbuf, strlen(inbuf), dest_code, src_code,
-                          &read_len, &written_len, NULL);
+       cd = iconv_open(dest_code, src_code);
+       if (cd == (iconv_t)-1)
+               return NULL;
+
+       outbuf = conv_iconv_strdup_with_cd(inbuf, cd);
+
+       iconv_close(cd);
+
+       return outbuf;
+}
+
+gchar *conv_iconv_strdup_with_cd(const gchar *inbuf, iconv_t cd)
+{
+       const gchar *inbuf_p;
+       gchar *outbuf;
+       gchar *outbuf_p;
+       size_t in_size;
+       size_t in_left;
+       size_t out_size;
+       size_t out_left;
+       size_t n_conv;
+       size_t len;
 
-       if (outbuf == NULL)
-               g_warning(_("Valid locale type set? (Currently: %s to %s)\n"),
-                         src_code, dest_code);
-       
-       return outbuf;                     
+       inbuf_p = inbuf;
+       in_size = strlen(inbuf);
+       in_left = in_size;
+       out_size = (in_size + 1) * 2;
+       outbuf = g_malloc(out_size);
+       outbuf_p = outbuf;
+       out_left = out_size;
+
+#define EXPAND_BUF()                           \
+{                                              \
+       len = outbuf_p - outbuf;                \
+       out_size *= 2;                          \
+       outbuf = g_realloc(outbuf, out_size);   \
+       outbuf_p = outbuf + len;                \
+       out_left = out_size - len;              \
+}
+
+       while ((n_conv = iconv(cd, (ICONV_CONST gchar **)&inbuf_p, &in_left,
+                              &outbuf_p, &out_left)) == (size_t)-1) {
+               if (EILSEQ == errno) {
+                       //g_print("iconv(): at %d: %s\n", in_size - in_left, g_strerror(errno));
+                       inbuf_p++;
+                       in_left--;
+                       if (out_left == 0) {
+                               EXPAND_BUF();
+                       }
+                       *outbuf_p++ = SUBST_CHAR;
+                       out_left--;
+               } else if (EINVAL == errno) {
+                       break;
+               } else if (E2BIG == errno) {
+                       EXPAND_BUF();
+               } else {
+                       g_warning("conv_iconv_strdup(): %s\n",
+                                 g_strerror(errno));
+                       break;
+               }
+       }
+
+       while ((n_conv = iconv(cd, NULL, NULL, &outbuf_p, &out_left)) ==
+              (size_t)-1) {
+               if (E2BIG == errno) {
+                       EXPAND_BUF();
+               } else {
+                       g_warning("conv_iconv_strdup(): %s\n",
+                                 g_strerror(errno));
+                       break;
+               }
+       }
+
+#undef EXPAND_BUF
+
+       len = outbuf_p - outbuf;
+       outbuf = g_realloc(outbuf, len + 1);
+       outbuf[len] = '\0';
+
+       return outbuf;
 }
 
 static const struct {
@@ -1004,6 +1111,7 @@ static const struct {
        {C_ISO_2022_JP_3,       CS_ISO_2022_JP_3},
        {C_EUC_JP,              CS_EUC_JP},
        {C_EUC_JP,              CS_EUCJP},
+       {C_EUC_JP_MS,           CS_EUC_JP_MS},
        {C_SHIFT_JIS,           CS_SHIFT_JIS},
        {C_SHIFT_JIS,           CS_SHIFT__JIS},
        {C_SHIFT_JIS,           CS_SJIS},
@@ -1260,7 +1368,7 @@ CharSet conv_get_charset_from_str(const gchar *charset)
        return GPOINTER_TO_UINT(g_hash_table_lookup(table, charset));
 }
 
-CharSet conv_get_current_charset(void)
+CharSet conv_get_locale_charset(void)
 {
        static CharSet cur_charset = -1;
        const gchar *cur_locale;
@@ -1309,14 +1417,24 @@ CharSet conv_get_current_charset(void)
        return cur_charset;
 }
 
-const gchar *conv_get_current_charset_str(void)
+const gchar *conv_get_locale_charset_str(void)
 {
        static const gchar *codeset = NULL;
 
        if (!codeset)
-               codeset = conv_get_charset_str(conv_get_current_charset());
+               codeset = conv_get_charset_str(conv_get_locale_charset());
+
+       return codeset ? codeset : CS_INTERNAL;
+}
 
-       return codeset ? codeset : CS_US_ASCII;
+CharSet conv_get_internal_charset(void)
+{
+       return C_INTERNAL;
+}
+
+const gchar *conv_get_internal_charset_str(void)
+{
+       return CS_INTERNAL;
 }
 
 CharSet conv_get_outgoing_charset(void)
@@ -1376,13 +1494,14 @@ const gchar *conv_get_outgoing_charset_str(void)
        out_charset = conv_get_outgoing_charset();
        str = conv_get_charset_str(out_charset);
 
-       return str ? str : CS_US_ASCII;
+       return str ? str : CS_UTF_8;
 }
 
 gboolean conv_is_multibyte_encoding(CharSet encoding)
 {
        switch (encoding) {
        case C_EUC_JP:
+       case C_EUC_JP_MS:
        case C_EUC_KR:
        case C_EUC_TW:
        case C_EUC_CN:
@@ -1404,24 +1523,15 @@ gboolean conv_is_multibyte_encoding(CharSet encoding)
 
 const gchar *conv_get_current_locale(void)
 {
-       static const gchar *cur_locale = NULL;
+       const gchar *cur_locale;
 
-       if (cur_locale != NULL)
-               return cur_locale;
-       
        cur_locale = g_getenv("LC_ALL");
-       if (!cur_locale || !strlen(cur_locale)) 
-               cur_locale = g_getenv("LC_CTYPE");
-       if (!cur_locale || !strlen(cur_locale)) 
-               cur_locale = g_getenv("LANG");
-       if (!cur_locale || !strlen(cur_locale)) 
-               cur_locale = setlocale(LC_CTYPE, NULL);
-
-       if (cur_locale && strlen(cur_locale)) {
-               gchar *tmp = g_strdup(cur_locale);
-               cur_locale = g_strdup(tmp);
-               g_free(tmp);
-       }
+       if (!cur_locale) cur_locale = g_getenv("LC_CTYPE");
+       if (!cur_locale) cur_locale = g_getenv("LANG");
+       if (!cur_locale) cur_locale = setlocale(LC_CTYPE, NULL);
+
+       debug_print("current locale: %s\n",
+                   cur_locale ? cur_locale : "(none)");
 
        return cur_locale;
 }
@@ -1431,17 +1541,10 @@ void conv_unmime_header_overwrite(gchar *str)
        gchar *buf;
        gint buflen;
        CharSet cur_charset;
-       const gchar *locale;
 
-       g_return_if_fail(str != NULL);
-       
-       cur_charset = conv_get_current_charset();
+       cur_charset = conv_get_locale_charset();
 
-#warning FIXME_GTK2
-/* Should we always ensure to convert? */
-       locale = conv_get_current_locale();
-
-       if (locale && !strncasecmp(locale, "ja", 2)) {
+       if (cur_charset == C_EUC_JP) {
                buflen = strlen(str) * 2 + 1;
                Xalloca(buf, buflen, return);
                conv_anytodisp(buf, buflen, str);
@@ -1457,13 +1560,11 @@ void conv_unmime_header_overwrite(gchar *str)
 void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
                        const gchar *charset)
 {
-       const gchar *locale;
+       CharSet cur_charset;
 
-       memset(outbuf, 0, outlen);
-       
-       locale = conv_get_current_locale();
+       cur_charset = conv_get_locale_charset();
 
-       if (locale && !strncasecmp(locale, "ja", 2)) {
+       if (cur_charset == C_EUC_JP) {
                gchar *buf;
                gint buflen;
 
@@ -1471,23 +1572,8 @@ void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
                Xalloca(buf, buflen, return);
                conv_anytodisp(buf, buflen, str);
                unmime_header(outbuf, buf);
-       } else {
-               gchar *tmp = NULL;
+       } else
                unmime_header(outbuf, str);
-               if (outbuf && !g_utf8_validate(outbuf, -1, NULL)) {
-                       if (strcmp(conv_get_current_charset_str(), CS_UTF_8))
-                               tmp = conv_codeset_strdup(outbuf,
-                                       conv_get_current_charset_str(),
-                                       CS_UTF_8);
-
-                       if (tmp) {
-                               strncpy(outbuf, tmp, outlen-1);
-                               g_free(tmp);
-                       } else {
-                               conv_localetodisp(outbuf, outlen, str);
-                       }
-               } 
-       }
 }
 
 #define MAX_LINELEN            76
@@ -1528,8 +1614,9 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
        const guchar *srcp = src;
        guchar *destp = dest;
        gboolean use_base64;
-       gchar *testbuf;
-       
+
+       g_return_if_fail(g_utf8_validate(src, -1, NULL) == TRUE);
+
        if (MB_CUR_MAX > 1) {
                use_base64 = TRUE;
                mimesep_enc = "?B?";
@@ -1538,19 +1625,11 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                mimesep_enc = "?Q?";
        }
 
-       cur_encoding = CS_UTF_8; /* gtk2 */
-
+       cur_encoding = CS_INTERNAL;
        out_encoding = conv_get_outgoing_charset_str();
        if (!strcmp(out_encoding, CS_US_ASCII))
                out_encoding = CS_ISO_8859_1;
 
-       testbuf = conv_codeset_strdup(src, cur_encoding, out_encoding);
-       
-       if (testbuf != NULL) 
-               g_free(testbuf);
-       else
-               out_encoding = CS_UTF_8;
-       
        mimestr_len = strlen(MIMESEP_BEGIN) + strlen(out_encoding) +
                strlen(mimesep_enc) + strlen(MIMESEP_END);
 
@@ -1608,14 +1687,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                if (addr_field && (*p == '(' || *p == ')'))
                                        break;
 
-                               if (MB_CUR_MAX > 1) {
-                                       mb_len = mblen(p, MB_CUR_MAX);
-                                       if (mb_len < 0) {
-                                               g_warning("conv_encode_header(): invalid multibyte character encountered\n");
-                                               mb_len = 1;
-                                       }
-                               } else
-                                       mb_len = 1;
+                               mb_len = g_utf8_skip[*p];
 
                                Xstrndup_a(part_str, srcp, cur_len + mb_len, );
                                out_str = conv_codeset_strdup
index 854e859..88c4295 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 #endif
 
 #include <glib.h>
+#include <iconv.h>
 
 typedef struct _CodeConverter  CodeConverter;
 
@@ -74,6 +75,7 @@ typedef enum
        C_ISO_2022_JP_2,
        C_ISO_2022_JP_3,
        C_EUC_JP,
+       C_EUC_JP_MS,
        C_SHIFT_JIS,
        C_ISO_2022_KR,
        C_EUC_KR,
@@ -145,6 +147,7 @@ struct _CodeConverter
 #define CS_ISO_2022_JP_3       "ISO-2022-JP-3"
 #define CS_EUC_JP              "EUC-JP"
 #define CS_EUCJP               "EUCJP"
+#define CS_EUC_JP_MS           "EUC-JP-MS"
 #define CS_SHIFT_JIS           "Shift_JIS"
 #define CS_SHIFT__JIS          "SHIFT-JIS"
 #define CS_SJIS                        "SJIS"
@@ -163,31 +166,17 @@ struct _CodeConverter
 #define CS_GEORGIAN_PS         "GEORGIAN-PS"
 #define CS_TCVN5712_1          "TCVN5712-1"
 
-void conv_jistoeuc     (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_euctojis     (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_sjistoeuc    (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytoeuc     (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytoutf8    (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytojis     (gchar *outbuf, gint outlen, const gchar *inbuf);
+#define C_INTERNAL             C_UTF_8
+#define CS_INTERNAL            CS_UTF_8
 
-void conv_unreadable_eucjp     (gchar *str);
-void conv_unreadable_8bit      (gchar *str);
-void conv_unreadable_latin     (gchar *str);
-void conv_unreadable_locale    (gchar *str);
-
-void conv_mb_alnum(gchar *str);
+//void conv_mb_alnum(gchar *str);
 
 CharSet conv_guess_ja_encoding(const gchar *str);
 
-void conv_jistodisp    (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_sjistodisp   (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_euctodisp    (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_ustodisp     (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_latintodisp  (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_noconv       (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_utf8todisp   (gchar *outbuf, gint outlen, const gchar *inbuf);
 void conv_localetodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
 
-CodeConverter *conv_code_converter_new (const gchar    *charset);
+CodeConverter *conv_code_converter_new (const gchar    *src_charset);
 void conv_code_converter_destroy       (CodeConverter  *conv);
 gint conv_convert                      (CodeConverter  *conv,
                                         gchar          *outbuf,
@@ -204,11 +193,15 @@ CodeConvFunc conv_get_code_conv_func      (const gchar    *src_charset_str,
 gchar *conv_iconv_strdup               (const gchar    *inbuf,
                                         const gchar    *src_code,
                                         const gchar    *dest_code);
+gchar *conv_iconv_strdup_with_cd       (const gchar    *inbuf,
+                                        iconv_t         cd);
 
 const gchar *conv_get_charset_str              (CharSet         charset);
 CharSet conv_get_charset_from_str              (const gchar    *charset);
-CharSet conv_get_current_charset               (void);
-const gchar *conv_get_current_charset_str      (void);
+CharSet conv_get_locale_charset                        (void);
+const gchar *conv_get_locale_charset_str       (void);
+CharSet conv_get_internal_charset              (void);
+const gchar *conv_get_internal_charset_str     (void);
 CharSet conv_get_outgoing_charset              (void);
 const gchar *conv_get_outgoing_charset_str     (void);
 gboolean conv_is_multibyte_encoding            (CharSet         encoding);
index 19f5fc9..d838ca1 100644 (file)
@@ -39,9 +39,6 @@ static Template *template_load(gchar *filename)
        FILE *fp;
        gchar buf[BUFFSIZE];
        gint bytes_read;
-#warning FIXME_GTK2
-       const gchar *src_codeset = conv_get_current_charset_str();
-       const gchar *dest_codeset = CS_UTF_8;
 
        if ((fp = fopen(filename, "rb")) == NULL) {
                FILE_OP_ERROR(filename, "fopen");
@@ -61,32 +58,14 @@ static Template *template_load(gchar *filename)
 
                if (buf[0] == '\n')
                        break;
-               else if (!g_ascii_strncasecmp(buf, "Name:", 5)) {
-                       tmp = conv_codeset_strdup(buf + 5,
-                                                 src_codeset,
-                                                 dest_codeset);
-                       tmpl->name = tmp ? g_strstrip(tmp) : g_strdup(buf + 5);
-               } else if (!g_ascii_strncasecmp(buf, "Subject:", 8)) {
-                       tmp = conv_codeset_strdup(buf + 8,
-                                                 src_codeset,
-                                                 dest_codeset);
-                       tmpl->subject = tmp ? g_strstrip(tmp) : g_strdup(buf + 8);
-               } else if (!g_ascii_strncasecmp(buf, "To:", 3)) {
-                       tmp = conv_codeset_strdup(buf + 3,
-                                                 src_codeset,
-                                                 dest_codeset);
-                       tmpl->to = tmp ? g_strstrip(tmp) : g_strdup(buf + 3);
-               } else if (!g_ascii_strncasecmp(buf, "Cc:", 3)) {
-                       tmp = conv_codeset_strdup(buf + 3,
-                                                 src_codeset,
-                                                 dest_codeset);
-                       tmpl->cc = tmp ? g_strstrip(tmp) : g_strdup(buf + 3);
-               } else if (!g_ascii_strncasecmp(buf, "Bcc:", 4)) {
-                       tmp = conv_codeset_strdup(buf + 4,
-                                                 src_codeset,
-                                                 dest_codeset);
-                       tmpl->bcc = tmp ? g_strstrip(tmp) : g_strdup(buf + 4);
-               }
+               else if (!g_ascii_strncasecmp(buf, "Name:", 5))
+                       tmpl->name = g_strdup(g_strstrip(buf + 5));
+               else if (!g_ascii_strncasecmp(buf, "To:", 3))
+                       tmpl->to = g_strdup(g_strstrip(buf + 3));
+               else if (!g_ascii_strncasecmp(buf, "Cc:", 3))
+                       tmpl->cc = g_strdup(g_strstrip(buf + 3));
+               else if (!g_ascii_strncasecmp(buf, "Subject:", 8))
+                       tmpl->subject = g_strdup(g_strstrip(buf + 8));
        }
 
        if (!tmpl->name) {
@@ -103,10 +82,7 @@ static Template *template_load(gchar *filename)
                }
        }
        fclose(fp);
-       buf[bytes_read] = '\0';
-       tmpl->value = conv_codeset_strdup(buf, src_codeset, dest_codeset);
-       if (!tmpl->value)
-               tmpl->value = g_strdup(buf);
+       tmpl->value = g_strndup(buf, bytes_read);
 
        return tmpl;
 }
@@ -161,7 +137,8 @@ GSList *template_read_config(void)
        while ((de = readdir(dp)) != NULL) {
                if (*de->d_name == '.') continue;
 
-               filename = g_strconcat(path, G_DIR_SEPARATOR_S, de->d_name, NULL);
+               filename = g_strconcat(path, G_DIR_SEPARATOR_S,
+                                      de->d_name, NULL);
 
                if (stat(filename, &s) != 0 || !S_ISREG(s.st_mode) ) {
                        debug_print("%s:%d %s is not an ordinary file\n",
@@ -172,6 +149,7 @@ GSList *template_read_config(void)
                tmpl = template_load(filename);
                if (tmpl)
                        tmpl_list = g_slist_append(tmpl_list, tmpl);
+
                g_free(filename);
        }
 
@@ -205,10 +183,6 @@ void template_write_config(GSList *tmpl_list)
 
        for (cur = tmpl_list, tmpl_num = 1; cur != NULL;
             cur = cur->next, tmpl_num++) {
-#warning FIXME_GTK2
-               const gchar *src_codeset = CS_UTF_8;
-               const gchar *dest_codeset = conv_get_current_charset_str();
-               gchar *tmp = NULL;
                gchar *filename;
 
                tmpl = cur->data;
@@ -222,55 +196,18 @@ void template_write_config(GSList *tmpl_list)
                        return;
                }
 
-               tmp = conv_codeset_strdup(tmpl->name, src_codeset, dest_codeset);
-               if (!tmp)
-                       tmp = g_strdup(tmpl->name);
-               fprintf(fp, "Name: %s\n", tmp ? tmp : "");
-               g_free(tmp);
-
-               if (tmpl->subject && *tmpl->subject != '\0') {
-                       tmp = conv_codeset_strdup(tmpl->subject,
-                                                 src_codeset, dest_codeset);
-                       if (!tmp)
-                               tmp = g_strdup(tmpl->subject);
-                       fprintf(fp, "Subject: %s\n", tmp);
-                       g_free(tmp);
-               }
-
-               if (tmpl->to && *tmpl->to != '\0') {
-                       tmp = conv_codeset_strdup(tmpl->to,
-                                                 src_codeset, dest_codeset);
-                       if (!tmp)
-                               tmp = g_strdup(tmpl->to);
-                       fprintf(fp, "To: %s\n", tmp);
-                       g_free(tmp);
-               }
-
-               if (tmpl->cc && *tmpl->cc != '\0') {
-                       tmp = conv_codeset_strdup(tmpl->cc,
-                                                 src_codeset, dest_codeset);
-                       if (!tmp)
-                               tmp = g_strdup(tmpl->cc);
-                       fprintf(fp, "Cc: %s\n", tmp);
-                       g_free(tmp);
-               }
-
-               if (tmpl->bcc && *tmpl->bcc != '\0') {
-                       tmp = conv_codeset_strdup(tmpl->bcc,
-                                                 src_codeset, dest_codeset);
-                       if (!tmp)
-                               tmp = g_strdup(tmpl->bcc);
-                       fprintf(fp, "Bcc: %s\n", tmp);
-                       g_free(tmp);
-               }
-
+               fprintf(fp, "Name: %s\n", tmpl->name);
+               if (tmpl->subject && *tmpl->subject != '\0')
+                       fprintf(fp, "Subject: %s\n", tmpl->subject);
+               if (tmpl->to && *tmpl->to != '\0')
+                       fprintf(fp, "To: %s\n", tmpl->to);
+               if (tmpl->cc && *tmpl->cc != '\0')
+                       fprintf(fp, "Cc: %s\n", tmpl->cc);
+               if (tmpl->cc && *tmpl->bcc != '\0')
+                       fprintf(fp, "Cc: %s\n", tmpl->bcc);
                fputs("\n", fp);
-               tmp = conv_codeset_strdup(tmpl->value,
-                                         src_codeset, dest_codeset);
-               if (!tmp)
-                       tmp = g_strdup(tmpl->value);
-               fwrite(tmp, sizeof(gchar) * strlen(tmp), 1, fp);
-               g_free(tmp);
+               fwrite(tmpl->value, sizeof(gchar) * strlen(tmpl->value), 1, fp);
+
                fclose(fp);
                g_free(filename);
        }
index 348a9ba..0454b8d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto & The Sylpheed-Claws Team
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto & The Sylpheed-Claws Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -544,11 +544,9 @@ gint get_mbs_len(const gchar *s)
                return -1;
 
        while (*p != '\0') {
-               mb_len = mblen(p, MB_LEN_MAX);
+               mb_len = g_utf8_skip[*(guchar *)p];
                if (mb_len == 0)
                        break;
-               else if (mb_len < 0)
-                       return -1;
                else
                        len++;
 
@@ -1422,17 +1420,17 @@ gchar *trim_string(const gchar *str, gint len)
        if (!str) return NULL;
        if (strlen(str) <= len)
                return g_strdup(str);
+       if (g_utf8_validate(str, -1, NULL) == FALSE)
+               return g_strdup(str);
 
        while (*p != '\0') {
-               mb_len = mblen(p, MB_LEN_MAX);
+               mb_len = g_utf8_skip[*(guchar *)p];
                if (mb_len == 0)
                        break;
-               else if (mb_len < 0)
-                       return g_strdup(str);
                else if (new_len + mb_len > len)
                        break;
-               else
-                       new_len += mb_len;
+
+               new_len += mb_len;
                p += mb_len;
        }
 
@@ -1479,7 +1477,7 @@ GList *uri_list_extract_filenames(const gchar *uri_list)
                                                        = conv_codeset_strdup(
                                                                file + 5,
                                                                CS_UTF_8,
-                                                               conv_get_current_charset_str());
+                                                               conv_get_locale_charset_str());
                                        if (!locale_file)
                                                locale_file = g_strdup(file + 5);
                                        result = g_list_append(result, locale_file);
@@ -3076,7 +3074,7 @@ gchar *file_read_stream_to_str(FILE *fp)
        if (!g_utf8_validate(str, -1, NULL)) {
                const gchar *src_codeset, *dest_codeset;
                gchar *tmp = NULL;
-               src_codeset = conv_get_current_charset_str();
+               src_codeset = conv_get_locale_charset_str();
                dest_codeset = CS_UTF_8;
                tmp = conv_codeset_strdup(str, src_codeset, dest_codeset);
                g_free(str);
@@ -3193,7 +3191,7 @@ gchar *get_command_output(const gchar *cmdline)
        if (!g_utf8_validate(ret, -1, NULL)) {
                const gchar *src_codeset, *dest_codeset;
                gchar *tmp = NULL;
-               src_codeset = conv_get_current_charset_str();
+               src_codeset = conv_get_locale_charset_str();
                dest_codeset = CS_UTF_8;
                tmp = conv_codeset_strdup(ret, src_codeset, dest_codeset);
                g_free(ret);
index d662144..628641f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -83,6 +83,7 @@ XMLFile *xml_open_file(const gchar *path)
        newfile->bufp = newfile->buf->str;
 
        newfile->dtd = NULL;
+       newfile->encoding = NULL;
        newfile->tag_stack = NULL;
        newfile->level = 0;
        newfile->is_empty_element = FALSE;
@@ -99,6 +100,7 @@ void xml_close_file(XMLFile *file)
        g_string_free(file->buf, TRUE);
 
        g_free(file->dtd);
+       g_free(file->encoding);
 
        while (file->tag_stack != NULL)
                xml_pop_tag(file);
@@ -167,9 +169,15 @@ gint xml_get_dtd(XMLFile *file)
        if ((*bufp++ == '?') &&
            (bufp = strcasestr(bufp, "xml")) &&
            (bufp = strcasestr(bufp + 3, "version")) &&
-           (bufp = strchr(bufp + 7, '?')))
+           (bufp = strchr(bufp + 7, '?'))) {
                file->dtd = g_strdup(buf);
-       else {
+               if ((bufp = strcasestr(buf, "encoding=\""))) {
+                       bufp += 9;
+                       extract_quote(bufp, '"');
+                       file->encoding = g_strdup(bufp);
+               } else
+                       file->encoding = g_strdup(CS_INTERNAL);
+       } else {
                g_warning("Can't get xml dtd\n");
                return -1;
        }
@@ -181,6 +189,7 @@ gint xml_parse_next_tag(XMLFile *file)
 {
        gchar buf[XMLBUFSIZE];
        guchar *bufp = buf;
+       gchar *tag_str;
        XMLTag *tag;
        gint len;
 
@@ -221,18 +230,30 @@ gint xml_parse_next_tag(XMLFile *file)
 
        while (*bufp != '\0' && !isspace(*bufp)) bufp++;
        if (*bufp == '\0') {
-               tag->tag = XML_STRING_ADD(buf);
+               tag_str = conv_codeset_strdup(buf, file->encoding, CS_INTERNAL);
+               if (tag_str) {
+                       tag->tag = XML_STRING_ADD(tag_str);
+                       g_free(tag_str);
+               } else
+                       tag->tag = XML_STRING_ADD(buf);
                return 0;
        } else {
                *bufp++ = '\0';
-               tag->tag = XML_STRING_ADD(buf);
+               tag_str = conv_codeset_strdup(buf, file->encoding, CS_INTERNAL);
+               if (tag_str) {
+                       tag->tag = XML_STRING_ADD(tag_str);
+                       g_free(tag_str);
+               } else
+                       tag->tag = XML_STRING_ADD(buf);
        }
 
        /* parse attributes ( name=value ) */
        while (*bufp) {
                XMLAttr *attr;
-               gchar *attr_name, *attr_value;
-               gchar *utf8attr_name, *utf8attr_value;
+               gchar *attr_name;
+               gchar *attr_value;
+               gchar *utf8_attr_name;
+               gchar *utf8_attr_value;
                gchar *p;
                gchar quote;
 
@@ -262,28 +283,20 @@ gint xml_parse_next_tag(XMLFile *file)
 
                g_strchomp(attr_name);
                xml_unescape_str(attr_value);
-
-               if (!g_utf8_validate(attr_name, -1, NULL))
-                       utf8attr_name  = conv_codeset_strdup
-                                       (attr_name,
-                                        conv_get_current_charset_str(),
-                                        CS_UTF_8);
-               else
-                       utf8attr_name = g_strdup(attr_name);
-               
-               if (!g_utf8_validate(attr_value, -1, NULL))
-                       utf8attr_value = conv_codeset_strdup
-                                       (attr_value,
-                                        conv_get_current_charset_str(),
-                                        CS_UTF_8);
-               else
-                       utf8attr_value = g_strdup(attr_value);
-                                       
-               attr = xml_attr_new(utf8attr_name, utf8attr_value);
+               utf8_attr_name = conv_codeset_strdup
+                       (attr_name, file->encoding, CS_INTERNAL);
+               utf8_attr_value = conv_codeset_strdup
+                       (attr_value, file->encoding, CS_INTERNAL);
+               if (!utf8_attr_name)
+                       utf8_attr_name = g_strdup(attr_name);
+               if (!utf8_attr_value)
+                       utf8_attr_value = g_strdup(attr_value);
+
+               attr = xml_attr_new(utf8_attr_name, utf8_attr_value);
                xml_tag_add_attr(tag, attr);
 
-               g_free(utf8attr_name);
-               g_free(utf8attr_value);
+               g_free(utf8_attr_value);
+               g_free(utf8_attr_name);
        }
 
        return 0;
@@ -331,8 +344,8 @@ GList *xml_get_current_tag_attr(XMLFile *file)
 gchar *xml_get_element(XMLFile *file)
 {
        gchar *str;
+       gchar *new_str;
        gchar *end;
-       gchar *utf8str;
 
        while ((end = strchr(file->bufp, '<')) == NULL)
                if (xml_read_line(file) < 0) return NULL;
@@ -353,18 +366,12 @@ gchar *xml_get_element(XMLFile *file)
                return NULL;
        }
 
-       utf8str = conv_codeset_strdup
-                       (str,
-                        conv_get_current_charset_str(),
-                        CS_UTF_8);
-       if (!utf8str) {
-               g_warning("xml_get_element(): "
-                         "faild to convert character set.\n");
-               utf8str = str;
-       } else
-               g_free(str);
+       new_str = conv_codeset_strdup(str, file->encoding, CS_INTERNAL);
+       if (!new_str)
+               new_str = g_strdup(str);
+       g_free(str);
 
-       return utf8str;
+       return new_str;
 }
 
 gint xml_read_line(XMLFile *file)
@@ -533,7 +540,7 @@ gint xml_unescape_str(gchar *str)
 gint xml_file_put_escape_str(FILE *fp, const gchar *str)
 {
        const gchar *src_codeset = CS_UTF_8;
-       const gchar *dest_codeset = conv_get_current_charset_str();
+       const gchar *dest_codeset = conv_get_locale_charset_str();
        gchar *tmpstr = NULL;
        const gchar *p;
 
@@ -578,8 +585,7 @@ gint xml_file_put_xml_decl(FILE *fp)
 {
        g_return_val_if_fail(fp != NULL, -1);
 
-       fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\"?>\n",
-       conv_get_current_charset_str());
+       fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\"?>\n", CS_INTERNAL);
        return 0;
 }
 
index e6b1cbc..705c62e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -56,6 +56,8 @@ struct _XMLFile
        gchar *bufp;
 
        gchar *dtd;
+       gchar *encoding;
+
        GList *tag_stack;
        guint level;
 
index 4fb8cee..d6ed44c 100644 (file)
@@ -2166,6 +2166,7 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
        GtkTextBuffer *buffer;
        GtkTextMark *mark;
        GtkTextIter iter;
+       const gchar *cur_encoding;
        gchar buf[BUFFSIZE];
        gint len;
        FILE *fp;
@@ -2187,14 +2188,12 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
                                        G_CALLBACK(text_inserted),
                                        compose);
 
+       cur_encoding = conv_get_locale_charset_str();
+
        while (fgets(buf, sizeof(buf), fp) != NULL) {
-               const gchar *cur_encoding = conv_get_current_charset_str();
-               gchar *str = NULL;
-               if (!g_utf8_validate(buf, -1, NULL))
-                       str = conv_codeset_strdup(buf, cur_encoding, CS_UTF_8);
-               else
-                       str = g_strdup(buf);
+               gchar *str;
 
+               str = conv_codeset_strdup(buf, cur_encoding, CS_INTERNAL);
                if (!str) continue;
 
                /* strip <CR> if DOS/Windows file,
@@ -2205,9 +2204,9 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
                        while (--len >= 0)
                                if (str[len] == '\r') str[len] = '\n';
                }
-               gtk_text_buffer_insert(buffer, &iter, str, -1);
 
-               g_free (str);
+               gtk_text_buffer_insert(buffer, &iter, str, -1);
+               g_free(str);
        }
 
        g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
@@ -2479,8 +2478,8 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
 }
 
 #define DISP_WIDTH(len) \
-       ((len > 2 && conv_get_current_charset() == C_UTF_8) ? 2 : \
-        (len == 2 && conv_get_current_charset() == C_UTF_8) ? 1 : len)
+       ((len > 2 && conv_get_locale_charset() == C_UTF_8) ? 2 : \
+        (len == 2 && conv_get_locale_charset() == C_UTF_8) ? 1 : len)
 
 #define SPACE_CHARS    " \t"
 
@@ -3637,7 +3636,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action)
                else
                        encoding = procmime_get_encoding_for_charset(out_codeset);
 
-               src_codeset = CS_UTF_8;
+               src_codeset = CS_INTERNAL;
                /* if current encoding is US-ASCII, set it the same as
                   outgoing one to prevent code conversion failure */
                if (!g_ascii_strcasecmp(src_codeset, CS_US_ASCII))
@@ -3746,9 +3745,9 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
        gtk_text_buffer_get_end_iter(buffer, &end);
        tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 
-       src_codeset = CS_UTF_8;
-       dest_codeset = conv_get_current_charset_str();
-       chars = conv_codeset_strdup(tmp, src_codeset, dest_codeset);
+       chars = conv_codeset_strdup
+               (tmp, CS_INTERNAL, conv_get_locale_charset_str());
+
        g_free(tmp);
        if (!chars) return -1;
 
@@ -5114,7 +5113,7 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
                    strcmp(prefs_common.dictionary, _("None"))) {
                        gtkaspell = gtkaspell_new(prefs_common.aspell_path,
                                                  prefs_common.dictionary,
-                                                 conv_get_current_charset_str(),
+                                                 conv_get_locale_charset_str(),
                                                  prefs_common.misspelled_col,
                                                  prefs_common.check_while_typing,
                                                  prefs_common.use_alternate,
index e2d7140..0be901b 100644 (file)
@@ -102,7 +102,7 @@ gint export_mbox(FolderItem *default_src)
                utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
                if (utf8mbox && *utf8mbox) {
                        const gchar *src_codeset = CS_UTF_8;
-                       const gchar *dest_codeset = conv_get_current_charset_str();
+                       const gchar *dest_codeset = conv_get_locale_charset_str();
                        gchar *mbox;
 
 #warning FIXME_GTK2 /* should we use g_filename_from_utf8()? */
@@ -236,7 +236,7 @@ static void export_filesel_cb(GtkWidget *widget, gpointer data)
        if (g_getenv ("G_BROKEN_FILENAMES")) {
                const gchar *oldstr = filename;
                filename = conv_codeset_strdup (filename,
-                                               conv_get_current_charset_str(),
+                                               conv_get_locale_charset_str(),
                                                CS_UTF_8);
                if (!filename) {
                        g_warning("export_filesel_cb(): faild to convert character set.");
index 054e11e..8bce886 100644 (file)
@@ -103,11 +103,14 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs);
 void folder_item_prefs_read_config(FolderItem * item)
 {
        gchar * id;
+       gchar *rcpath;
 
        id = folder_item_get_identifier(item);
        folder_item_prefs_clear(&tmp_prefs);
-       prefs_read_config(param, id, FOLDERITEM_RC);
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, FOLDERITEM_RC, NULL);
+       prefs_read_config(param, id, rcpath, NULL);
        g_free(id);
+       g_free(rcpath);
 
        *item->prefs = tmp_prefs;
 
index 67e55ef..d95579b 100644 (file)
@@ -1913,7 +1913,7 @@ static GtkMenu *make_sug_menu(GtkAspell *gtkaspell)
                        }
 
                        utf8buf  = conv_codeset_strdup((unsigned char*)l->data,
-                                                       conv_get_current_charset_str(),
+                                                       conv_get_locale_charset_str(),
                                                        CS_UTF_8);
                        item = gtk_menu_item_new_with_label(utf8buf);
                        gtk_widget_show(item);
index f38fceb..d7833a0 100644 (file)
@@ -375,7 +375,7 @@ HTMLParser *html_parser_new(FILE *fp, CodeConverter *conv)
                  conv->charset == C_ISO_2022_JP_2 ||
                  conv->charset == C_EUC_JP        ||
                  conv->charset == C_SHIFT_JIS) &&
-                conv_get_current_charset() == C_EUC_JP)
+                conv_get_locale_charset() == C_EUC_JP)
                parser->symbol_table = eucjp_symbol_table;
        else
                parser->symbol_table = default_symbol_table;
@@ -456,7 +456,7 @@ static HTMLState html_read_line(HTMLParser *parser)
        if (conv_convert(parser->conv, buf2, sizeof(buf2), buf) < 0) {
                index = parser->bufp - parser->buf->str;
 
-               conv_localetodisp(buf2, sizeof(buf2), buf);
+               conv_utf8todisp(buf2, sizeof(buf2), buf);
                g_string_append(parser->buf, buf2);
 
                parser->bufp = parser->buf->str + index;
index efa78c9..98bf832 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -3366,24 +3366,6 @@ static void imap_path_separator_subst(gchar *str, gchar separator)
 
 static gchar *imap_modified_utf7_to_utf8(const gchar *mutf7_str)
 {
-#if !HAVE_ICONV
-       const gchar *from_p;
-       gchar *to, *to_p;
-
-       to = g_malloc(strlen(mutf7_str) + 1);
-       to_p = to;
-
-       for (from_p = mutf7_str; *from_p != '\0'; from_p++) {
-               if (*from_p == '&' && *(from_p + 1) == '-') {
-                       *to_p++ = '&';
-                       from_p++;
-               } else
-                       *to_p++ = *from_p;
-       }
-       *to_p = '\0';
-
-       return to;
-#else
        static iconv_t cd = (iconv_t)-1;
        static gboolean iconv_ok = TRUE;
        GString *norm_utf7;
@@ -3397,14 +3379,16 @@ static gchar *imap_modified_utf7_to_utf8(const gchar *mutf7_str)
        if (!iconv_ok) return g_strdup(mutf7_str);
 
        if (cd == (iconv_t)-1) {
-               cd = iconv_open(conv_get_current_charset_str(), CS_UTF_8);
+               cd = iconv_open(CS_INTERNAL, CS_UTF_7);
                if (cd == (iconv_t)-1) {
-                       g_warning(_("iconv cannot convert UTF-7 to UTF-8\n"));
+                       g_warning("iconv cannot convert UTF-7 to %s\n",
+                                 CS_INTERNAL);
                        iconv_ok = FALSE;
                        return g_strdup(mutf7_str);
                }
        }
 
+       /* modified UTF-7 to normal UTF-7 conversion */
        norm_utf7 = g_string_new(NULL);
 
        for (p = mutf7_str; *p != '\0'; p++) {
@@ -3436,7 +3420,8 @@ static gchar *imap_modified_utf7_to_utf8(const gchar *mutf7_str)
 
        if (iconv(cd, (ICONV_CONST gchar **)&norm_utf7_p, &norm_utf7_len,
                  &to_p, &to_len) == -1) {
-               g_warning(_("iconv cannot convert UTF-7 to UTF-8\n"));
+               g_warning(_("iconv cannot convert UTF-7 to %s\n"),
+                         conv_get_locale_charset_str());
                g_string_free(norm_utf7, TRUE);
                g_free(to_str);
                return g_strdup(mutf7_str);
@@ -3448,29 +3433,10 @@ static gchar *imap_modified_utf7_to_utf8(const gchar *mutf7_str)
        *to_p = '\0';
 
        return to_str;
-#endif /* !HAVE_ICONV */
 }
 
 static gchar *imap_utf8_to_modified_utf7(const gchar *from)
 {
-#if !HAVE_ICONV
-       const gchar *from_p;
-       gchar *to, *to_p;
-
-       to = g_malloc(strlen(from) * 2 + 1);
-       to_p = to;
-
-       for (from_p = from; *from_p != '\0'; from_p++) {
-               if (*from_p == '&') {
-                       *to_p++ = '&';
-                       *to_p++ = '-';
-               } else
-                       *to_p++ = *from_p;
-       }
-       *to_p = '\0';
-
-       return to;
-#else
        static iconv_t cd = (iconv_t)-1;
        static gboolean iconv_ok = TRUE;
        gchar *norm_utf7, *norm_utf7_p;
@@ -3482,14 +3448,16 @@ static gchar *imap_utf8_to_modified_utf7(const gchar *from)
        if (!iconv_ok) return g_strdup(from);
 
        if (cd == (iconv_t)-1) {
-               cd = iconv_open("UTF-7", CS_UTF_8);
+               cd = iconv_open(CS_UTF_7, CS_INTERNAL);
                if (cd == (iconv_t)-1) {
-                       g_warning("iconv cannot convert UTF-8 to UTF-7\n");
+                       g_warning(_("iconv cannot convert %s to UTF-7\n"),
+                                 CS_INTERNAL);
                        iconv_ok = FALSE;
                        return g_strdup(from);
                }
        }
 
+       /* UTF-8 to normal UTF-7 conversion */
        Xstrdup_a(from_tmp, from, return g_strdup(from));
        from_len = strlen(from);
        norm_utf7_len = from_len * 5;
@@ -3513,18 +3481,13 @@ static gchar *imap_utf8_to_modified_utf7(const gchar *from)
                        from_tmp++;
                        from_len--;
                } else {
-                       size_t mb_len = 0, conv_len = 0;
+                       size_t conv_len = 0;
 
                        /* unprintable char: convert to UTF-7 */
                        p = from_tmp;
                        while (!IS_PRINT(*(guchar *)p) && conv_len < from_len) {
-                               mb_len = mblen(p, MB_LEN_MAX);
-                               if (mb_len <= 0) {
-                                       g_warning("wrong multibyte sequence\n");
-                                       return g_strdup(from);
-                               }
-                               conv_len += mb_len;
-                               p += mb_len;
+                               conv_len += g_utf8_skip[*(guchar *)p];
+                               p += g_utf8_skip[*(guchar *)p];
                        }
 
                        from_len -= conv_len;
@@ -3578,7 +3541,6 @@ static gchar *imap_utf8_to_modified_utf7(const gchar *from)
        g_string_free(to_str, FALSE);
 
        return to;
-#endif /* !HAVE_ICONV */
 }
 
 static GSList *imap_get_seq_set_from_numlist(MsgNumberList *numlist)
index a4548b3..642594a 100644 (file)
@@ -98,14 +98,10 @@ gint import_mbox(FolderItem *default_dest)
                utf8filename = gtk_entry_get_text(GTK_ENTRY(file_entry));
                destdir = gtk_entry_get_text(GTK_ENTRY(dest_entry));
                if (utf8filename && *utf8filename) {
-                       const gchar *src_codeset = CS_UTF_8;
-                       const gchar *dest_codeset = conv_get_current_charset_str();
                        gchar *filename;
 
-#warning FIXME_GTK2 /* should we use g_filename_from_utf8? */
-                       filename = conv_codeset_strdup(utf8filename,
-                                                      src_codeset,
-                                                      dest_codeset);
+                       filename = g_filename_from_utf8
+                               (utf8filename, -1, NULL, NULL, NULL);
                        if (!filename) {
                                g_warning("faild to convert character set\n");
                                filename = g_strdup(utf8filename);
@@ -235,23 +231,18 @@ static void import_cancel_cb(GtkWidget *widget, gpointer data)
 static void import_filesel_cb(GtkWidget *widget, gpointer data)
 {
        gchar *filename;
+       gchar *utf8_filename;
 
        filename = filesel_select_file_open(_("Select importing file"), NULL);
        if (!filename) return;
 
-       if (g_getenv ("G_BROKEN_FILENAMES")) {
-               const gchar *oldstr = filename;
-               filename = conv_codeset_strdup (filename,
-                                               conv_get_current_charset_str(),
-                                               CS_UTF_8);
-               if (!filename) {
-                       g_warning("import_filesel_cb(): faild to convert character set.");
-                       filename = g_strdup(oldstr);
-               }
-               gtk_entry_set_text(GTK_ENTRY(file_entry), filename);
-               g_free(filename);
-       } else
-               gtk_entry_set_text(GTK_ENTRY(file_entry), filename);
+       utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
+       if (!utf8_filename) {
+               g_warning("import_filesel_cb(): faild to convert characer set.");
+               utf8_filename = g_strdup(filename);
+       }
+       gtk_entry_set_text(GTK_ENTRY(file_entry), utf8_filename);
+       g_free(utf8_filename);
 }
 
 static void import_destsel_cb(GtkWidget *widget, gpointer data)
index 4ab882b..c700065 100644 (file)
@@ -53,6 +53,7 @@
 #include "jpilot.h"
 #include "codeconv.h"
 #include "adbookbase.h"
+#include "utils.h"
 
 #define JPILOT_DBHOME_DIR   ".jpilot"
 #define JPILOT_DBHOME_FILE  "AddressDB.pdb"
@@ -1099,8 +1100,10 @@ static void jpilot_parse_label( JPilotFile *pilotFile, gchar *labelEntry, ItemPe
                        email = addritem_create_item_email();
                        addritem_email_set_address( email, node->data );
                        if (convert_charcode) {
-                               conv_sjistoeuc(convertBuff, JPILOT_LEN_LABEL, buffer);
-                               addritem_email_set_remarks(email, convertBuff);
+                               gchar *convertBuff;
+                               convertBuff = conv_codeset_strdup( ai->labels[ind], CS_SHIFT_JIS, CS_INTERNAL );
+                               addritem_email_set_remarks( email, convertBuff );
+                               g_free( convertBuff );
                        }
                        else {
                                addritem_email_set_remarks(email, buffer);
@@ -1180,8 +1183,8 @@ static void jpilot_load_address(
 
                if( convert_charcode ) {
                        gchar *nameConv;
-                       nameConv = g_strdup( fullName );
-                       conv_sjistoeuc( fullName, FULLNAME_BUFSIZE, nameConv );
+                       nameConv = conv_codeset_strdup( fullName, CS_SHIFT_JIS, CS_INTERNAL );
+                       strncpy2( fullName, nameConv, FULLNAME_BUFSIZE );
                        g_free( nameConv );
                }
 
@@ -1218,7 +1221,6 @@ static void jpilot_load_address(
                /* Add entry for each custom label */
                node = pilotFile->labelInd;
                while( node ) {
-                       gchar convertBuff[JPILOT_LEN_LABEL];
                        gint ind;
 
                        ind = GPOINTER_TO_INT( node->data );
@@ -1348,7 +1350,9 @@ static gboolean jpilot_setup_labels( JPilotFile *pilotFile ) {
                                gchar convertBuff[ JPILOT_LEN_LABEL ];
 
                                if( convert_charcode ) {
-                                       conv_sjistoeuc( convertBuff, JPILOT_LEN_LABEL, labelName );
+                                       labelName = conv_codeset_strdup( labelName, CS_SHIFT_JIS, CS_INTERNAL );
+                                       strncpy2( convertBuff, labelName, JPILOT_LEN_LABEL );
+                                       g_free( labelName );
                                        labelName = convertBuff;
                                }
 
@@ -1381,14 +1385,15 @@ GList *jpilot_load_label( JPilotFile *pilotFile, GList *labelList ) {
                struct AddressAppInfo *ai = & pilotFile->addrInfo;
                for( i = 0; i < JPILOT_NUM_LABELS; i++ ) {
                        gchar *labelName = ai->labels[i];
-                       gchar convertBuff[JPILOT_LEN_LABEL];
 
                        if( labelName ) {
                                if( convert_charcode ) {
-                                       conv_sjistoeuc( convertBuff, JPILOT_LEN_LABEL, labelName );
-                                       labelName = convertBuff;
+                                       labelName = conv_codeset_strdup( labelName, CS_SHIFT_JIS, CS_INTERNAL );
                                }
-                               labelList = g_list_append( labelList, g_strdup( labelName ) );
+                               else {
+                                       labelName = g_strdup( labelName );
+                               }
+                               labelList = g_list_append( labelList, labelName );
                        }
                        else {
                                labelList = g_list_append(
@@ -1461,7 +1466,6 @@ GList *jpilot_load_phone_label( JPilotFile *pilotFile, GList *labelList ) {
  */
 GList *jpilot_load_custom_label( JPilotFile *pilotFile, GList *labelList ) {
        gint i;
-       char convertBuff[JPILOT_LEN_LABEL];
 
        g_return_val_if_fail( pilotFile != NULL, NULL );
 
@@ -1474,10 +1478,12 @@ GList *jpilot_load_custom_label( JPilotFile *pilotFile, GList *labelList ) {
                                g_strchug( labelName );
                                if( *labelName != '\0' ) {
                                        if( convert_charcode ) {
-                                               conv_sjistoeuc( convertBuff, JPILOT_LEN_LABEL, labelName );
-                                               labelName = convertBuff;
+                                               labelName = conv_codeset_strdup( labelName, CS_SHIFT_JIS, CS_INTERNAL );
+                                       }
+                                       else {
+                                               labelName = g_strdup( labelName );
                                        }
-                                       labelList = g_list_append( labelList, g_strdup( labelName ) );
+                                       labelList = g_list_append( labelList, labelName );
                                }
                        }
                }
@@ -1527,9 +1533,10 @@ static void jpilot_build_category_list( JPilotFile *pilotFile ) {
                ItemFolder *folder = addritem_create_item_folder();
 
                if( convert_charcode ) {
-                       gchar catName[ JPILOT_LEN_CATEG ];
-                       conv_sjistoeuc( catName, JPILOT_LEN_CATEG, cat->name[i] );
+                       gchar *catName;
+                       catName = conv_codeset_strdup( cat->name[i], CS_SHIFT_JIS, CS_INTERNAL );
                        addritem_folder_set_name( folder, catName );
+                       g_free( catName );
                }
                else {
                        addritem_folder_set_name( folder, cat->name[i] );
index 41749ee..8525b86 100644 (file)
@@ -556,17 +556,14 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
         CODESET_ACTION(C_US_ASCII)},
 
-#if HAVE_ICONV
        {N_("/_View/_Code set/Unicode (_UTF-8)"),
         CODESET_ACTION(C_UTF_8)},
        CODESET_SEPARATOR,
-#endif
        {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
         CODESET_ACTION(C_ISO_8859_1)},
        {N_("/_View/_Code set/Western European (ISO-8859-15)"),
         CODESET_ACTION(C_ISO_8859_15)},
        CODESET_SEPARATOR,
-#if HAVE_ICONV
        {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
         CODESET_ACTION(C_ISO_8859_2)},
        CODESET_SEPARATOR,
@@ -590,18 +587,14 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
         CODESET_ACTION(C_WINDOWS_1251)},
        CODESET_SEPARATOR,
-#endif
        {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
         CODESET_ACTION(C_ISO_2022_JP)},
-#if HAVE_ICONV
        {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
         CODESET_ACTION(C_ISO_2022_JP_2)},
-#endif
        {N_("/_View/_Code set/Japanese (_EUC-JP)"),
         CODESET_ACTION(C_EUC_JP)},
        {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
         CODESET_ACTION(C_SHIFT_JIS)},
-#if HAVE_ICONV
        CODESET_SEPARATOR,
        {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
         CODESET_ACTION(C_GB2312)},
@@ -621,7 +614,6 @@ static GtkItemFactoryEntry mainwin_entries[] =
         CODESET_ACTION(C_TIS_620)},
        {N_("/_View/_Code set/Thai (Windows-874)"),
         CODESET_ACTION(C_WINDOWS_874)},
-#endif
 
 #undef CODESET_SEPARATOR
 #undef CODESET_ACTION
index 53a3412..8e1bacb 100644 (file)
@@ -82,7 +82,7 @@ void matcher_parser_init(void)
                BEGIN(0);
                *string_buf_ptr = '\0';
                if (!g_utf8_validate(string_buf, -1, NULL)) {
-                       gchar *tmp = conv_codeset_strdup(string_buf, conv_get_current_charset_str(), CS_UTF_8);
+                       gchar *tmp = conv_codeset_strdup(string_buf, conv_get_locale_charset_str(), CS_INTERNAL);
                        if (tmp) {
                                strcpy(string_buf, tmp);
                                g_free(tmp);
index 16aac78..6172c89 100644 (file)
@@ -178,17 +178,14 @@ static GtkItemFactoryEntry msgview_entries[] =
        {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
         CODESET_ACTION(C_US_ASCII)},
 
-#if HAVE_ICONV
        {N_("/_View/_Code set/Unicode (_UTF-8)"),
         CODESET_ACTION(C_UTF_8)},
        CODESET_SEPARATOR,
-#endif
        {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
         CODESET_ACTION(C_ISO_8859_1)},
        {N_("/_View/_Code set/Western European (ISO-8859-15)"),
         CODESET_ACTION(C_ISO_8859_15)},
        CODESET_SEPARATOR,
-#if HAVE_ICONV
        {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
         CODESET_ACTION(C_ISO_8859_2)},
        CODESET_SEPARATOR,
@@ -212,18 +209,14 @@ static GtkItemFactoryEntry msgview_entries[] =
        {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
         CODESET_ACTION(C_CP1251)},
        CODESET_SEPARATOR,
-#endif
        {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
         CODESET_ACTION(C_ISO_2022_JP)},
-#if HAVE_ICONV
        {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
         CODESET_ACTION(C_ISO_2022_JP_2)},
-#endif
        {N_("/_View/_Code set/Japanese (_EUC-JP)"),
         CODESET_ACTION(C_EUC_JP)},
        {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
         CODESET_ACTION(C_SHIFT_JIS)},
-#if HAVE_ICONV
        CODESET_SEPARATOR,
        {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
         CODESET_ACTION(C_GB2312)},
@@ -243,7 +236,6 @@ static GtkItemFactoryEntry msgview_entries[] =
         CODESET_ACTION(C_TIS_620)},
        {N_("/_View/_Code set/Thai (Windows-874)"),
         CODESET_ACTION(C_WINDOWS_874)},
-#endif
 
 #undef CODESET_SEPARATOR
 #undef CODESET_ACTION
index 33a6306..0e73f8c 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -938,7 +938,7 @@ static gboolean mh_rename_folder_func(GNode *node, gpointer data)
 static gchar *mh_filename_from_utf8(const gchar *path)
 {
        const gchar *src_codeset = CS_UTF_8;
-       const gchar *dest_codeset = conv_get_current_charset_str();
+       const gchar *dest_codeset = conv_get_locale_charset_str();
        gchar *real_path;
 
        real_path = conv_codeset_strdup(path, src_codeset, dest_codeset);
@@ -954,7 +954,7 @@ static gchar *mh_filename_from_utf8(const gchar *path)
 #warning FIXME_GTK2 /* should we use g_filename_to_utf8()? */
 static gchar *mh_filename_to_utf8(const gchar *path)
 {
-       const gchar *src_codeset = conv_get_current_charset_str();
+       const gchar *src_codeset = conv_get_locale_charset_str();
        const gchar *dest_codeset = CS_UTF_8;
        gchar *utf8path;
 
index 4116bb1..ee83e38 100644 (file)
@@ -195,6 +195,8 @@ void clamav_set_message_callback(MessageCallback callback)
 
 gint plugin_init(gchar **error)
 {
+       gchar *rcpath;
+       
        if ((sylpheed_get_version() > VERSION_NUMERIC)) {
                *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
                return -1;
@@ -212,8 +214,10 @@ gint plugin_init(gchar **error)
        }
 
        prefs_set_default(param);
-       prefs_read_config(param, "ClamAV", COMMON_RC);
-
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+       prefs_read_config(param, "ClamAV", rcpath, NULL);
+       g_free(rcpath);
+       
        debug_print("ClamAV plugin loaded\n");
 
        return 0;
index 4a7fec0..c102250 100644 (file)
@@ -69,13 +69,16 @@ static void save_dillo_prefs                (PrefsPage *page);
 void dillo_prefs_init(void)
 {
        static gchar *path[3];
+       gchar *rcpath;
 
        path[0] = _("Message View");
        path[1] = _("Dillo Browser");
        path[2] = NULL;
 
         prefs_set_default(param);
-        prefs_read_config(param, PREFS_BLOCK_NAME, COMMON_RC);
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+        prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
+       g_free(rcpath);
         
         prefs_page.page.path = path;
         prefs_page.page.create_widget = create_dillo_prefs_page;
index 5708e89..99ee420 100644 (file)
@@ -148,13 +148,16 @@ static struct ImageViewerPage imageviewer_page;
 void image_viewer_prefs_init(void)
 {
        static gchar *path[3];
+       gchar *rcpath;
 
        path[0] = _("Message View");
        path[1] = _("Image Viewer");
        path[2] = NULL;
 
        prefs_set_default(param);
-       prefs_read_config(param, PREFS_BLOCK_NAME, COMMON_RC);
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+       prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
+       g_free(rcpath);
 
        imageviewer_page.page.path = path;
        imageviewer_page.page.create_widget = imageviewer_create_widget_func;
index 4fdeb2a..2ab2d90 100644 (file)
@@ -76,8 +76,6 @@ passphrase_mbox (const gchar *desc)
 {
     gchar *the_passphrase = NULL;
     GtkWidget *vbox;
-    GtkWidget *table;
-    GtkWidget *pass_label;
     GtkWidget *confirm_box;
     GtkWidget *window;
     GtkWidget *pass_entry;
@@ -88,7 +86,6 @@ passphrase_mbox (const gchar *desc)
     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(window), _("Passphrase"));
     gtk_widget_set_size_request(window, 450, -1);
-    gtk_container_set_border_width(GTK_CONTAINER(window), 4);
     gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
     gtk_window_set_modal(GTK_WINDOW(window), TRUE);
     gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
@@ -101,46 +98,24 @@ passphrase_mbox (const gchar *desc)
 
     vbox = gtk_vbox_new(FALSE, 8);
     gtk_container_add(GTK_CONTAINER(window), vbox);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
 
     if (desc) {
         GtkWidget *label;
         label = create_description (desc);
-        gtk_box_pack_start (GTK_BOX(vbox), label, TRUE, TRUE, 0);
+        gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0);
     }
 
-    table = gtk_table_new(2, 2, FALSE);
-    gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
-    gtk_container_set_border_width(GTK_CONTAINER(table), 8);
-    gtk_table_set_row_spacings(GTK_TABLE(table), 12);
-    gtk_table_set_col_spacings(GTK_TABLE(table), 8);
-
-
-    pass_label = gtk_label_new("");
-    gtk_table_attach (GTK_TABLE(table), pass_label, 0, 1, 0, 1,
-                      GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0);
-    gtk_misc_set_alignment (GTK_MISC (pass_label), 1, 0.5);
-
     pass_entry = gtk_entry_new();
-    gtk_table_attach (GTK_TABLE(table), pass_entry, 1, 2, 0, 1,
-                      GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
-    gtk_entry_set_visibility (GTK_ENTRY(pass_entry), FALSE);
-    gtk_widget_grab_focus (pass_entry);
-
-
-    confirm_box = gtk_hbutton_box_new ();
-    gtk_button_box_set_layout (GTK_BUTTON_BOX(confirm_box), GTK_BUTTONBOX_END);
-    gtk_box_set_spacing (GTK_BOX(confirm_box), 5);
-
-    ok_button = gtk_button_new_with_label (_("OK"));
-    GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
-    gtk_box_pack_start (GTK_BOX(confirm_box), ok_button, TRUE, TRUE, 0);
-
-    cancel_button = gtk_button_new_with_label (_("Cancel"));
-    GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
-    gtk_box_pack_start(GTK_BOX(confirm_box), cancel_button, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), pass_entry, FALSE, FALSE, 0);
+    gtk_entry_set_visibility(GTK_ENTRY(pass_entry), FALSE);
+    gtk_widget_grab_focus(pass_entry);
 
+    gtkut_stock_button_set_create(&confirm_box, &ok_button, GTK_STOCK_OK,
+                                 &cancel_button, GTK_STOCK_CANCEL,
+                                 NULL, NULL);
     gtk_box_pack_end(GTK_BOX(vbox), confirm_box, FALSE, FALSE, 0);
-    gtk_widget_grab_default (ok_button);
+    gtk_widget_grab_default(ok_button);
 
     g_signal_connect(G_OBJECT(ok_button), "clicked",
                     G_CALLBACK(passphrase_ok_cb), NULL);
@@ -281,6 +256,7 @@ create_description (const gchar *desc)
                            linelen (uid), uid, linelen (info), info);
 
     label = gtk_label_new (buf);
+    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
     g_free (buf);
 
     return label;
index 7ecf66e..33f616f 100644 (file)
@@ -489,9 +489,12 @@ static struct GPGAccountPage gpg_account_page;
 void prefs_gpg_init()
 {
        static gchar *path[3];
+       gchar *rcpath;
 
        prefs_set_default(param);
-       prefs_read_config(param, "GPG", COMMON_RC);
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+       prefs_read_config(param, "GPG", rcpath, NULL);
+       g_free(rcpath);
 
         path[0] = _("Privacy");
         path[1] = _("GPG");
index 35975b3..3986561 100644 (file)
@@ -37,7 +37,7 @@
 #include <gtk/gtkentry.h>
 #include <gtk/gtkhbbox.h>
 #include <gtk/gtkbutton.h>
-#include <gtk/gtksignal.h>
+#include <gtk/gtkstock.h>
 
 #include "intl.h"
 #include "select-keys.h"
@@ -341,10 +341,10 @@ create_dialog (struct select_keys_s *sk)
     g_signal_connect(G_OBJECT (showall_btn), "clicked",
                      G_CALLBACK(showall_btn_cb), sk);
 
-    gtkut_button_set_create (&bbox, 
-                             &select_btn, _("Select"),
-                             &cancel_btn, _("Cancel"),
-                             &other_btn,  _("Other"));
+    gtkut_stock_button_set_create (&bbox, 
+                                   &select_btn, _("Select"),
+                                   &cancel_btn, GTK_STOCK_CANCEL,
+                                   &other_btn,  _("Other"));
     gtk_box_pack_end (GTK_BOX (hbox), bbox, FALSE, FALSE, 0);
     gtk_widget_grab_default (select_btn);
 
index a9860d0..c4f6dcd 100644 (file)
@@ -278,6 +278,8 @@ void spamassassin_set_message_callback(MessageCallback callback)
 
 gint plugin_init(gchar **error)
 {
+       gchar *rcpath;
+
        if ((sylpheed_get_version() > VERSION_NUMERIC)) {
                *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
                return -1;
@@ -301,7 +303,9 @@ gint plugin_init(gchar **error)
        }
 
        prefs_set_default(param);
-       prefs_read_config(param, "SpamAssassin", COMMON_RC);
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+       prefs_read_config(param, "SpamAssassin", rcpath, NULL);
+       g_free(rcpath);
 
        debug_print("Spamassassin plugin loaded\n");
 
index d07fdef..a2a5df7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -697,6 +697,7 @@ PrefsAccount *prefs_account_new(void)
 void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
 {
        const guchar *p = label;
+       gchar *rcpath;
        gint id;
        gchar **strv, **cur;
 
@@ -706,7 +707,10 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
        memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
        tmp_ac_prefs.privacy_prefs = ac_prefs->privacy_prefs;
 
-       prefs_read_config(param, label, ACCOUNT_RC);
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
+       prefs_read_config(param, label, rcpath, NULL);
+       g_free(rcpath);
+
        *ac_prefs = tmp_ac_prefs;
        while (*p && !isdigit(*p)) p++;
        id = atoi(p);
index 146f3d3..5a7bf67 100644 (file)
@@ -330,7 +330,7 @@ void prefs_actions_read_config(void)
        }
 
        while (fgets(buf, sizeof(buf), fp) != NULL) {
-               const gchar *src_codeset = conv_get_current_charset_str();
+               const gchar *src_codeset = conv_get_locale_charset_str();
                const gchar *dest_codeset = CS_UTF_8;
                gchar *tmp;
 
@@ -371,7 +371,7 @@ void prefs_actions_write_config(void)
        for (cur = prefs_common.actions_list; cur != NULL; cur = cur->next) {
                gchar *tmp = (gchar *)cur->data;
                const gchar *src_codeset = CS_UTF_8;
-               const gchar *dest_codeset = conv_get_current_charset_str();
+               const gchar *dest_codeset = conv_get_locale_charset_str();
                gchar *act;
 
                act = conv_codeset_strdup(tmp, src_codeset, dest_codeset);
index f6c1250..f20aa2a 100644 (file)
@@ -872,8 +872,12 @@ GList *prefs_common_read_history(const gchar *history)
 
 void prefs_common_read_config(void)
 {
-       prefs_read_config(param, "Common", COMMON_RC);
-
+       gchar *rcpath;
+       
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
+       prefs_read_config(param, "Common", rcpath, NULL);
+       g_free(rcpath);
+       
        prefs_common.mime_open_cmd_history =
                prefs_common_read_history(COMMAND_HISTORY);
        prefs_common.summary_quicksearch_history =
@@ -1230,9 +1234,7 @@ static void prefs_send_create(void)
 
        SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
        SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
-#if HAVE_ICONV
        SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
-#endif
        SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
        SET_MENUITEM(_("Western European (ISO-8859-15)"), CS_ISO_8859_15);
        SET_MENUITEM(_("Central European (ISO-8859-2)"),  CS_ISO_8859_2);
@@ -1240,14 +1242,10 @@ static void prefs_send_create(void)
        SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
        SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
        SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
-#if HAVE_ICONV
        SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
-#endif
        SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
-#if HAVE_ICONV
        SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
        SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
-#endif
        SET_MENUITEM(_("Japanese (ISO-2022-JP)"),        CS_ISO_2022_JP);
 #if 0
        SET_MENUITEM(_("Japanese (EUC-JP)"),             CS_EUC_JP);
@@ -2225,7 +2223,7 @@ static void date_format_entry_on_change(GtkEditable *editable,
        g_free(text);
 
        text = conv_codeset_strdup(buffer,
-                                  conv_get_current_charset_str(),
+                                  conv_get_locale_charset_str(),
                                   CS_UTF_8);
        if (!text)
                text = g_strdup(buffer);
index ff0f208..864f68f 100644 (file)
@@ -50,11 +50,10 @@ typedef enum
 } DummyEnum;
 
 void prefs_read_config(PrefParam *param, const gchar *label,
-                      const gchar *rcfile)
+                      const gchar *rcfile, const gchar *encoding)
 {
        FILE *fp;
        gchar buf[PREFSBUFSIZE];
-       gchar *rcpath;
        gchar *block_label;
 
        g_return_if_fail(param != NULL);
@@ -65,13 +64,10 @@ void prefs_read_config(PrefParam *param, const gchar *label,
 
        prefs_set_default(param);
 
-       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, rcfile, NULL);
-       if ((fp = fopen(rcpath, "rb")) == NULL) {
-               if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
-               g_free(rcpath);
+       if ((fp = fopen(rcfile, "rb")) == NULL) {
+               if (ENOENT != errno) FILE_OP_ERROR(rcfile, "fopen");
                return;
        }
-       g_free(rcpath);
 
        block_label = g_strdup_printf("[%s]", label);
 
@@ -79,7 +75,18 @@ void prefs_read_config(PrefParam *param, const gchar *label,
        while (fgets(buf, sizeof(buf), fp) != NULL) {
                gint val;
 
-               val = strncmp(buf, block_label, strlen(block_label));
+               if (encoding) {
+                       gchar *conv_str;
+
+                       conv_str = conv_codeset_strdup
+                               (buf, encoding, CS_INTERNAL);
+                       if (!conv_str)
+                               conv_str = g_strdup(buf);
+                       val = strncmp
+                               (conv_str, block_label, strlen(block_label));
+                       g_free(conv_str);
+               } else
+                       val = strncmp(buf, block_label, strlen(block_label));
                if (val == 0) {
                        debug_print("Found %s\n", block_label);
                        break;
@@ -92,7 +99,17 @@ void prefs_read_config(PrefParam *param, const gchar *label,
                /* reached next block */
                if (buf[0] == '[') break;
 
-               prefs_config_parse_one_line(param, buf);
+               if (encoding) {
+                       gchar *conv_str;
+
+                       conv_str = conv_codeset_strdup
+                               (buf, encoding, CS_INTERNAL);
+                       if (!conv_str)
+                               conv_str = g_strdup(buf);
+                       prefs_config_parse_one_line(param, conv_str);
+                       g_free(conv_str);
+               } else
+                       prefs_config_parse_one_line(param, buf);
        }
 
        debug_print("Finished reading configuration.\n");
@@ -122,7 +139,7 @@ void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
 
                        tmp = *value ?
                                conv_codeset_strdup(value,
-                                                   conv_get_current_charset_str(),
+                                                   conv_get_locale_charset_str(),
                                                    CS_UTF_8)
                                : g_strdup("");
                        if (!tmp) {
@@ -275,7 +292,7 @@ gint prefs_write_param(PrefParam *param, FILE *fp)
                        if (*((gchar **)param[i].data)) {
                                tmp = conv_codeset_strdup(*((gchar **)param[i].data),
                                                          CS_UTF_8,
-                                                         conv_get_current_charset_str());
+                                                         conv_get_locale_charset_str());
                                if (!tmp)
                                        tmp = g_strdup(*((gchar **)param[i].data));
                        }
@@ -365,7 +382,7 @@ void prefs_set_default(PrefParam *param)
                                        envstr = g_getenv(param[i].defval + 4);
                                        tmp = envstr && *envstr ?
                                                conv_codeset_strdup(envstr,
-                                                                   conv_get_current_charset_str(),
+                                                                   conv_get_locale_charset_str(),
                                                                    CS_UTF_8)
                                                : g_strdup("");
                                        if (!tmp) {
index f4e9e89..037997f 100644 (file)
@@ -135,7 +135,8 @@ struct _PrefsDialog
 
 void prefs_read_config         (PrefParam      *param,
                                 const gchar    *label,
-                                const gchar    *rcfile);
+                                const gchar    *rcfile,
+                                const gchar    *encoding);
 void prefs_config_parse_one_line(PrefParam     *param,
                                 const gchar    *buf);
 void prefs_write_config                (PrefParam      *param,
index 5620e5e..a331837 100644 (file)
@@ -581,7 +581,7 @@ static void prefs_themes_update_buttons(const ThemesData *tdata)
                                                                        \
        if (!g_utf8_validate(text, -1, NULL))                           \
                tmpstr = conv_codeset_strdup(text,                      \
-                       conv_get_current_charset_str(), CS_UTF_8);      \
+                       conv_get_locale_charset_str(),  CS_UTF_8);      \
        else                                                            \
                tmpstr = g_strdup(text);                                \
                                                                        \
index 941873f..0dba69f 100644 (file)
@@ -958,7 +958,7 @@ void procheader_date_get_localtime(gchar *dest, gint len, const time_t timer)
        else
                strftime(dest, len, default_format, lt);
 
-       src_codeset = conv_get_current_charset_str();
+       src_codeset = conv_get_locale_charset_str();
        dest_codeset = CS_UTF_8;
        str = conv_codeset_strdup(dest, src_codeset, dest_codeset);
        if (str) {
index b6b33d0..da75412 100644 (file)
@@ -1780,7 +1780,7 @@ static void write_parameters(gpointer key, gpointer value, gpointer user_data)
 
        case ENC_AS_EXTENDED:
                g_string_append_printf(buf, "%s*=%s''", param,
-                       conv_get_current_charset_str());
+                       conv_get_locale_charset_str());
                for (valpos = val; *valpos != '\0'; valpos++) {
                        if (IS_ASCII(*valpos) && isalnum(*valpos)) {
                                g_string_append_printf(buf, "%c", *valpos);
index ec53571..e68f739 100644 (file)
@@ -163,22 +163,10 @@ void source_window_append(SourceWindow *sourcewin, const gchar *str)
 
        len = strlen(str) + 1;
        Xalloca(out, len, return);
-       
-       conv_localetodisp(out, len, str);
-       if (!g_utf8_validate(out, -1, NULL)) {
-               gchar *buf;
-               gint buflen;
-               const gchar *src_codeset, *dest_codeset;
-               src_codeset = conv_get_current_charset_str();
-               dest_codeset = CS_UTF_8;
-               buf = conv_codeset_strdup(out, src_codeset, dest_codeset);
-               gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
-               gtk_text_buffer_insert(buffer, &iter, buf, -1);
-               g_free(buf);
-       } else {
-               gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
-               gtk_text_buffer_insert(buffer, &iter, out, -1);
-       }
+       conv_utf8todisp(out, len, str);
+
+       gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
+       gtk_text_buffer_insert(buffer, &iter, out, -1);
 }
 
 static void source_window_size_alloc_cb(GtkWidget *widget,
index 33463ee..af91864 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ GtkWidget *statusbar_create(void)
        GtkWidget *statusbar;
 
        statusbar = gtk_statusbar_new();
-
+       gtk_widget_set_size_request(statusbar, 1, -1);
        statusbar_list = g_list_append(statusbar_list, statusbar);
        gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(statusbar), 
                                          FALSE);
@@ -54,26 +54,12 @@ void statusbar_puts(GtkStatusbar *statusbar, const gchar *str)
 {
        gint cid;
        gchar *buf;
+       gchar *tmp;
 
-       buf = g_strdup(str);
-       strretchomp(buf);
-       if (strlen(buf) > 76) {
-               wchar_t *wbuf;
-
-               wbuf = strdup_mbstowcs(buf);
-
-               if (wcslen(wbuf) > 60) {
-                       gchar *tmp;
-
-                       g_free(buf);
-                       wbuf[60] = (wchar_t)0;
-                       tmp = strdup_wcstombs(wbuf);
-                       buf = g_strconcat(tmp, "...", NULL);
-                       g_free(tmp);
-               }
-
-               g_free(wbuf);
-       }
+       tmp = g_strdup(str);
+       strretchomp(tmp);
+       buf = trim_string(tmp, 76);
+       g_free(tmp);
 
        cid = gtk_statusbar_get_context_id(statusbar, "Standard Output");
        gtk_statusbar_pop(statusbar, cid);
index c1ba97b..343d141 100644 (file)
@@ -3344,7 +3344,7 @@ void summary_save_as(SummaryView *summaryview)
                gchar *oldstr = filename;
                filename = conv_codeset_strdup(filename,
                                               CS_UTF_8,
-                                              conv_get_current_charset_str());
+                                              conv_get_locale_charset_str());
                if (!filename) {
                        g_warning("summary_save_as(): faild to convert character set.");
                        filename = g_strdup(oldstr);
index 0adce34..8e3c0b1 100644 (file)
@@ -1155,11 +1155,10 @@ static void textview_write_line(TextView *textview, const gchar *str,
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
-       if (!conv) {
+       if (!conv)
                strncpy2(buf, str, sizeof(buf));
-       } else if (conv_convert(conv, buf, sizeof(buf), str) < 0) {
-               conv_localetodisp(buf, sizeof(buf), str);
-       }
+       else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
+               conv_utf8todisp(buf, sizeof(buf), str);
 
        strcrchomp(buf);
        //if (prefs_common.conv_mb_alnum) conv_mb_alnum(buf);
@@ -1220,23 +1219,10 @@ void textview_write_link(TextView *textview, const gchar *str,
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
-#warning FIXME_GTK2
-#if 0
-       if (!conv) {
-               if (textview->text_is_mb)
-                       conv_localetodisp(buf, sizeof(buf), str);
-               else
-                       strncpy2(buf, str, sizeof(buf));
-       } else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
-               conv_localetodisp(buf, sizeof(buf), str);
-       else if (textview->text_is_mb)
-               conv_unreadable_locale(buf);
-#else
        if (!conv)
                strncpy2(buf, str, sizeof(buf));
        else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
-               conv_localetodisp(buf, sizeof(buf), str);
-#endif
+               conv_utf8todisp(buf, sizeof(buf), str);
 
        strcrchomp(buf);
 
index 3dc9063..48b28bd 100644 (file)
@@ -528,8 +528,7 @@ void toolbar_save_config_file(ToolbarType source)
        g_free( fileSpec );
        if( pfile ) {
                fp = pfile->fp;
-               fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n",
-                       conv_get_current_charset_str());
+               fprintf(fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL);
 
                fprintf(fp, "<%s>\n", TOOLBAR_TAG_INDEX);
 
index a3183d7..65d279f 100644 (file)
@@ -112,15 +112,15 @@ void unmime_header(gchar *out, const gchar *str)
                        continue;
                }
 
-               /* convert to locale encoding */
-               conv_str = conv_codeset_strdup(decoded_text, charset, CS_UTF_8);
+               /* convert to UTF-8 */
+               conv_str = conv_codeset_strdup(decoded_text, charset, NULL);
                if (conv_str) {
                        len = strlen(conv_str);
                        memcpy(outp, conv_str, len);
                        g_free(conv_str);
                } else {
                        len = strlen(decoded_text);
-                       conv_localetodisp(outp, len + 1, decoded_text);
+                       conv_utf8todisp(outp, len + 1, decoded_text);
                }
                outp += len;