/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
+ * Copyright (C) 1999-2007 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
state = JIS_AUXKANJI; \
}
+static CodeConvFunc conv_get_code_conv_func (const gchar *src_charset_str,
+ const gchar *dest_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);
+static gboolean conv_is_ja_locale (void);
+
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);
}
}
-CharSet conv_guess_ja_encoding(const gchar *str)
+static CharSet conv_guess_ja_encoding(const gchar *str)
{
const guchar *p = str;
CharSet guessed = C_US_ASCII;
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_noconv) {
return conv_iconv_strdup(inbuf, src_code, dest_code);
}
-CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
+static CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
const gchar *dest_charset_str)
{
CodeConvFunc code_conv = conv_noconv;
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;
{"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},
return GPOINTER_TO_UINT(g_hash_table_lookup(table, charset));
}
-CharSet conv_get_locale_charset(void)
+static CharSet conv_get_locale_charset(void)
{
static CharSet cur_charset = -1;
const gchar *cur_locale;
return cur_charset;
}
- if (strcasestr(cur_locale, "UTF-8")) {
+ if (strcasestr(cur_locale, ".UTF-8") ||
+ strcasestr(cur_locale, ".utf8")) {
cur_charset = C_UTF_8;
return cur_charset;
}
return codeset ? codeset : CS_INTERNAL;
}
-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)
+static CharSet conv_get_outgoing_charset(void)
{
static CharSet out_charset = -1;
const gchar *cur_locale;
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:
- case C_ISO_2022_JP:
- case C_ISO_2022_JP_2:
- case C_ISO_2022_JP_3:
- case C_ISO_2022_KR:
- case C_ISO_2022_CN:
- case C_SHIFT_JIS:
- case C_GB2312:
- case C_GBK:
- case C_BIG5:
- case C_UTF_8:
- case C_UTF_7:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
const gchar *conv_get_current_locale(void)
{
const gchar *cur_locale;
return cur_locale;
}
-gboolean conv_is_ja_locale(void)
+static gboolean conv_is_ja_locale(void)
{
static gint is_ja_locale = -1;
const gchar *cur_locale;
continue;
}
- /* don't include parentheses in encoded strings */
- if (addr_field && (*srcp == '(' || *srcp == ')')) {
+ /* don't include parentheses and quotes in encoded strings */
+ if (addr_field && (*srcp == '(' || *srcp == ')' || *srcp == '"')) {
LBREAK_IF_REQUIRED(left < 2, FALSE);
*destp++ = *srcp++;
left--;
break;
/* don't include parentheses in encoded
strings */
- if (addr_field && (*p == '(' || *p == ')'))
+ if (addr_field && (*p == '(' || *p == ')' || *p == '"'))
break;
mb_len = g_utf8_skip[*p];