aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-06-19 04:20:38 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-06-19 04:20:38 +0000
commitbaa40e286ae263b6223ea651382b1e7ff332800e (patch)
tree1861780f51ea80838079ec9d96ae5d1914796ee6
parentc33aef05f2459480863b8b36ac813b3a8b3ad42c (diff)
added function to change the behavior of character encoding auto-detection.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2019 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.ja7
-rw-r--r--libsylph/codeconv.c18
-rw-r--r--libsylph/codeconv.h10
4 files changed, 40 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2616f4e2..b6c02457 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-19
+
+ * libsylph/codeconv.[ch]:
+ conv_set_autodetect_type()
+ conv_get_autodetect_type(): added function to change the behavior
+ of character encoding auto-detection.
+
2008-06-18
* libsylph/procmime.c: procmime_scan_mime_header(): also use
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 17a8426d..4ad9abf4 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,10 @@
+2008-06-19
+
+ * libsylph/codeconv.[ch]:
+ conv_set_autodetect_type()
+ conv_get_autodetect_type(): 文字エンコーディングの自動判別の動作を
+ 変更する関数を追加。
+
2008-06-18
* libsylph/procmime.c: procmime_scan_mime_header(): ファイルタイプ
diff --git a/libsylph/codeconv.c b/libsylph/codeconv.c
index 6408372d..08f60e22 100644
--- a/libsylph/codeconv.c
+++ b/libsylph/codeconv.c
@@ -154,6 +154,8 @@ typedef enum
state = JIS_UDC; \
}
+static ConvADType conv_ad_type = C_AD_BY_LOCALE;
+
static gchar *conv_jistoeuc(const gchar *inbuf, gint *error);
static gchar *conv_jistosjis(const gchar *inbuf, gint *error);
static gchar *conv_euctojis(const gchar *inbuf, gint *error);
@@ -1373,7 +1375,8 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_encoding,
/* auto detection mode */
if (!src_encoding && !dest_encoding) {
- if (conv_is_ja_locale())
+ if (conv_ad_type == C_AD_JAPANESE ||
+ (conv_ad_type == C_AD_BY_LOCALE && conv_is_ja_locale()))
return conv_anytodisp;
else
return conv_noconv;
@@ -2087,6 +2090,16 @@ gboolean conv_is_ja_locale(void)
return is_ja_locale != 0;
}
+void conv_set_autodetect_type(ConvADType type)
+{
+ conv_ad_type = type;
+}
+
+ConvADType conv_get_autodetect_type(void)
+{
+ return conv_ad_type;
+}
+
gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding)
{
gchar *buf;
@@ -2105,7 +2118,8 @@ gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding)
}
}
- if (conv_is_ja_locale())
+ if (conv_ad_type == C_AD_JAPANESE ||
+ (conv_ad_type == C_AD_BY_LOCALE && conv_is_ja_locale()))
buf = conv_anytodisp(str, NULL);
else
buf = conv_localetodisp(str, NULL);
diff --git a/libsylph/codeconv.h b/libsylph/codeconv.h
index 6e1391ab..121de0da 100644
--- a/libsylph/codeconv.h
+++ b/libsylph/codeconv.h
@@ -95,6 +95,13 @@ typedef enum
C_ISO_8859_16
} CharSet;
+typedef enum
+{
+ C_AD_BY_LOCALE,
+ C_AD_NEVER,
+ C_AD_JAPANESE
+} ConvADType;
+
typedef gchar *(*CodeConvFunc) (const gchar *inbuf, gint *error);
struct _CodeConverter
@@ -224,6 +231,9 @@ gboolean conv_is_multibyte_encoding (CharSet encoding);
const gchar *conv_get_current_locale (void);
gboolean conv_is_ja_locale (void);
+void conv_set_autodetect_type (ConvADType type);
+ConvADType conv_get_autodetect_type (void);
+
gchar *conv_unmime_header (const gchar *str,
const gchar *default_encoding);
void conv_encode_header (gchar *dest,