/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 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
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include "defs.h"
#include "codeconv.h"
#include "unmime.h"
-#include "base64.h"
#include "quoted-printable.h"
#include "utils.h"
#include "prefs_common.h"
{"ru_RU.KOI8-R" , C_KOI8_R , C_KOI8_R},
{"ru_RU.KOI8R" , C_KOI8_R , C_KOI8_R},
{"ru_RU.CP1251" , C_WINDOWS_1251, C_KOI8_R},
+#ifdef G_OS_WIN32
+ {"ru_RU" , C_WINDOWS_1251, C_KOI8_R},
+#else
{"ru_RU" , C_ISO_8859_5 , C_KOI8_R},
+#endif
{"tg_TJ" , C_KOI8_T , C_KOI8_T},
{"ru_UA" , C_KOI8_U , C_KOI8_U},
{"uk_UA.CP1251" , C_WINDOWS_1251, C_KOI8_U},
return cur_charset;
}
- if (strcasestr(cur_locale, ".UTF-8") ||
- strcasestr(cur_locale, ".utf8")) {
+ if (strcasestr(cur_locale, "UTF-8") ||
+ strcasestr(cur_locale, "utf8")) {
cur_charset = C_UTF_8;
return cur_charset;
}
static CharSet cur_charset = -1;
const gchar *cur_locale;
const gchar *p;
- gchar *tmp;
gint i;
- if (prefs_common.broken_are_utf8)
- return conv_get_locale_charset();
-
- if (cur_charset != -1)
+ if (prefs_common.broken_are_utf8) {
+ cur_charset = C_UTF_8;
return cur_charset;
+ }
cur_locale = conv_get_current_locale();
if (!cur_locale) {
return cur_charset;
}
- if (strcasestr(cur_locale, "UTF-8")) {
- tmp = g_strdup(cur_locale);
- *(strcasestr(tmp, ".UTF-8")) = '\0';
- cur_locale = tmp;
+ if (strcasestr(cur_locale, "UTF-8") ||
+ strcasestr(cur_locale, "utf8")) {
+ cur_charset = C_UTF_8;
+ return cur_charset;
}
if ((p = strcasestr(cur_locale, "@euro")) && p[5] == '\0') {
return out_charset;
}
- if (strcasestr(cur_locale, "UTF-8")) {
+ if (strcasestr(cur_locale, "UTF-8") ||
+ strcasestr(cur_locale, "utf8")) {
out_charset = C_UTF_8;
return out_charset;
}
} \
}
+#define B64LEN(len) ((len) / 3 * 4 + ((len) % 3 ? 4 : 0))
+
void conv_encode_header_full(gchar *dest, gint len, const gchar *src,
gint header_len, gboolean addr_field,
const gchar *out_encoding_)
cur_len += mb_len;
p += mb_len;
} else if (cur_len == 0) {
+ left = 0;
LBREAK_IF_REQUIRED(1, FALSE);
continue;
} else {
out_enc_str_len =
qp_get_q_encoding_len(out_str);
- Xalloca(enc_str, out_enc_str_len + 1, );
if (use_base64)
- base64_encode(enc_str, out_str, out_str_len);
- else
+ enc_str = g_base64_encode(out_str, out_str_len);
+ else {
+ Xalloca(enc_str, out_enc_str_len + 1, );
qp_q_encode(enc_str, out_str);
+ }
g_free(out_str);
g_snprintf(destp, mime_block_len + 1,
MIMESEP_BEGIN "%s%s%s" MIMESEP_END,
out_encoding, mimesep_enc, enc_str);
+
+ if (use_base64)
+ g_free(enc_str);
+
destp += mime_block_len;
srcp += cur_len;
}
#undef LBREAK_IF_REQUIRED
+#undef B64LEN
+
gchar *conv_filename_from_utf8(const gchar *utf8_file)
{
gchar *fs_file;