2009-01-10 [colin] 3.7.0cvs27
[claws.git] / src / codeconv.c
index 87081b0e63ead015eedde2677f73ee7a87260849..50bb708d91692bd7afa08a62e47f59a77f244a41 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail 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
@@ -114,6 +114,10 @@ static CodeConvFunc conv_get_code_conv_func        (const gchar    *src_charset_str,
 static gchar *conv_iconv_strdup_with_cd        (const gchar    *inbuf,
                                         iconv_t         cd);
 
+static gchar *conv_iconv_strdup                (const gchar    *inbuf,
+                                        const gchar    *src_code,
+                                        const gchar    *dest_code);
+
 static CharSet conv_get_locale_charset                 (void);
 static CharSet conv_get_outgoing_charset               (void);
 static CharSet conv_guess_ja_encoding(const gchar *str);
@@ -716,8 +720,14 @@ gchar *conv_codeset_strdup(const gchar *inbuf,
        size_t len;
        CodeConvFunc conv_func;
 
+       if (!strcmp2(src_code, dest_code))
+               return g_strdup(inbuf);
+
        src_code = conv_get_fallback_for_private_encoding(src_code);
        conv_func = conv_get_code_conv_func(src_code, dest_code);
+       if (conv_func == conv_ustodisp && strict_mode && !is_ascii_str(inbuf))
+               return NULL;
+
        if (conv_func != conv_noconv) {
                len = (strlen(inbuf) + 1) * 3;
                buf = g_malloc(len);
@@ -815,7 +825,7 @@ static CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
        return code_conv;
 }
 
-gchar *conv_iconv_strdup(const gchar *inbuf,
+static gchar *conv_iconv_strdup(const gchar *inbuf,
                         const gchar *src_code, const gchar *dest_code)
 {
        iconv_t cd;
@@ -1100,6 +1110,7 @@ static const struct {
        {"ms_MY"        , C_ISO_8859_1  , C_ISO_8859_1},
        {"nl_BE"        , C_ISO_8859_1  , C_ISO_8859_1},
        {"nl_NL"        , C_ISO_8859_1  , C_ISO_8859_1},
+       {"nb_NO"        , C_ISO_8859_1  , C_ISO_8859_1},
        {"nn_NO"        , C_ISO_8859_1  , C_ISO_8859_1},
        {"no_NO"        , C_ISO_8859_1  , C_ISO_8859_1},
        {"oc_FR"        , C_ISO_8859_1  , C_ISO_8859_1},
@@ -1508,6 +1519,16 @@ gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding)
                                *destp++ = ' ';                         \
                                left = MAX_LINELEN - 1;                 \
                        }                                               \
+               } else if (destp == (guchar *)dest && left < 7) {       \
+                       if (isspace(*(destp - 1)))                      \
+                               destp--;                                \
+                       else if (is_plain_text && isspace(*srcp))       \
+                               srcp++;                                 \
+                       if (*srcp) {                                    \
+                               *destp++ = '\n';                        \
+                               *destp++ = ' ';                         \
+                               left = MAX_LINELEN - 1;                 \
+                       }                                               \
                }                                                       \
        }                                                               \
 }
@@ -1699,7 +1720,7 @@ gchar *conv_filename_from_utf8(const gchar *utf8_file)
 
        fs_file = g_filename_from_utf8(utf8_file, -1, NULL, NULL, &error);
        if (error) {
-               g_warning("failed to convert encoding of file name: %s\n",
+               debug_print("failed to convert encoding of file name: %s\n",
                          error->message);
                g_error_free(error);
        }