* src/codeconv.c
[claws.git] / src / codeconv.c
index becdccfae66a362881eaeb9341dcdda12b1a3be4..566efdda66c98083fac7b7b1bbccaddd4fad32d9 100644 (file)
@@ -375,11 +375,11 @@ gchar *conv_codeset_strdup(const gchar *inbuf,
            == 0)
                return buf;
        else
-               return NULL;
+               return g_strdup(inbuf);
 #else /* !HAVE_LIBJCONV */
        if (src_codeset) {
                if (!strcasecmp(src_codeset, CS_EUC_JP) ||
-                   !strcasecmp(src_codeset, "EUCJP"))
+                   !strcasecmp(src_codeset, CS_EUCJP))
                        src_charset = C_EUC_JP;
                else if (!strcasecmp(src_codeset, CS_SHIFT_JIS) ||
                         !strcasecmp(src_codeset, "SHIFT-JIS") ||
@@ -435,7 +435,7 @@ CodeConvFunc conv_get_code_conv_func(const gchar *charset)
                 !strcasecmp(charset, "X-SJIS"))
                code_conv = conv_sjistodisp;
        else if (!strcasecmp(charset, CS_EUC_JP) ||
-                !strcasecmp(charset, "EUCJP"))
+                !strcasecmp(charset, CS_EUCJP))
                code_conv = conv_euctodisp;
        else
                code_conv = conv_noconv;
@@ -457,6 +457,7 @@ static const struct {
        {C_ISO_8859_7,          CS_ISO_8859_7},
        {C_ISO_8859_8,          CS_ISO_8859_8},
        {C_ISO_8859_9,          CS_ISO_8859_9},
+       {C_ISO_8859_11,         CS_ISO_8859_11},
        {C_ISO_8859_13,         CS_ISO_8859_13},
        {C_ISO_8859_15,         CS_ISO_8859_15},
        {C_BALTIC,              CS_BALTIC},
@@ -467,6 +468,7 @@ static const struct {
        {C_ISO_2022_JP,         CS_ISO_2022_JP},
        {C_ISO_2022_JP_2,       CS_ISO_2022_JP_2},
        {C_EUC_JP,              CS_EUC_JP},
+       {C_EUC_JP,              CS_EUCJP},
        {C_SHIFT_JIS,           CS_SHIFT_JIS},
        {C_ISO_2022_KR,         CS_ISO_2022_KR},
        {C_EUC_KR,              CS_EUC_KR},
@@ -475,6 +477,8 @@ static const struct {
        {C_GB2312,              CS_GB2312},
        {C_EUC_TW,              CS_EUC_TW},
        {C_BIG5,                CS_BIG5},
+       {C_TIS_620,             CS_TIS_620},
+       {C_WINDOWS_874,         CS_WINDOWS_874},
 };
 
 #if !HAVE_LIBJCONV
@@ -525,6 +529,10 @@ static const struct {
        {"iw_IL"        , C_ISO_8859_8},
        {"tr_TR"        , C_ISO_8859_9},
 
+       {"th_TH"        , C_TIS_620},
+       /* {"th_TH"     , C_WINDOWS_874}, */
+       /* {"th_TH"     , C_ISO_8859_11}, */
+
        {"lt_LT.iso88594"       , C_ISO_8859_4},
        {"lt_LT.ISO8859-4"      , C_ISO_8859_4},
        {"lt_LT.ISO_8859-4"     , C_ISO_8859_4},
@@ -811,7 +819,6 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                strlen(mimehdr_charset) + strlen(mimehdr_enctype);
        mimehdr_begin_len = strlen(mimehdr_init) +
                strlen(mimehdr_charset) + strlen(mimehdr_enctype);
-       /* line_len = 1; */
        line_len = header_len;
        destp = dest;
        *dest = '\0';
@@ -874,8 +881,8 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                }
                                /* g_free(raw); */
                                src_codeset = conv_get_current_charset_str();
-                               /* printf ("tmp = %s, tlen = %d, mbl\n", 
-                                       tmp, tlen, mbl); */
+                               /* printf ("tmp = %s, tlen = %d, mbl\n",
+                                       tmp, tlen, mbl); */
                                if (jconv_alloc_conv(tmp, tlen + mbl,
                                                     &raw_new, &raw_new_len,
                                                     &src_codeset, 1,
@@ -883,6 +890,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                    != 0) {
                                        g_warning("can't convert\n");
                                        tmpp[0] = '\0';
+                                       wtmpp++;
                                        continue;
                                }
                                if (!str_ascii) {
@@ -932,10 +940,8 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
 
                                wtmpp++;
                        }
-                       /*
-                         g_print("tmp = %s, tlen = %d, mb_seqlen = %d\n",
-                               tmp, tlen, mb_seqlen);
-                       */                              
+                       /* g_print("tmp = %s, tlen = %d, mb_seqlen = %d\n",
+                               tmp, tlen, mb_seqlen); */
 
                        if (tlen == 0 || raw_len == 0) {
                                g_free(tmp);
@@ -990,7 +996,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
 
        g_free(wsrc);
 
-       /* g_print("dest = %s\n", dest);  */
+       /* g_print("dest = %s\n", dest); */
 }
 #else /* !HAVE_LIBJCONV */
 
@@ -1023,7 +1029,6 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                      strlen(mimehdr_charset) + strlen(mimehdr_enctype);
        mimehdr_begin_len = strlen(mimehdr_init) +
                            strlen(mimehdr_charset) + strlen(mimehdr_enctype);
-       /* line_len = 1; */
        line_len = header_len;
        destp = dest;
        *dest = '\0';
@@ -1123,8 +1128,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                wtmpp++;
                        }
                        /* g_print("tmp = %s, tlen = %d, mb_seqlen = %d\n",
-                               tmp, tlen, mb_seqlen);
-                       */                              
+                               tmp, tlen, mb_seqlen); */
 
                        if (tlen == 0) {
                                g_free(tmp);