aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-12 06:19:36 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-12 06:19:36 +0000
commit761f4d1834b3217b5f9926baf0b9824234b51ef9 (patch)
treebf006b24963b66441e93a0f1af982b5e1e88af43
parentdd27e28c7d5de8e229a5a46fc35f3e24f050dcb1 (diff)
made workaround for UTF-8 with BOM.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1150 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.ja5
-rw-r--r--libsylph/codeconv.c16
-rw-r--r--src/compose.c2
4 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 10fb9823..3cf3869a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2006-09-12
+ * libsylph/codeconv.c
+ src/compose.c: made workaround for UTF-8 with BOM.
+
+2006-09-12
+
* src/ldif.[ch]: supported base64 encoded entries.
Supported "mozillaNickname" entry.
Use cn for display name if exists.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 6a7daf50..5160c636 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,10 @@
2006-09-12
+ * libsylph/codeconv.c
+ src/compose.c: BOM 付き UTF-8 への対処を行った。
+
+2006-09-12
+
* src/ldif.[ch]: base64 エンコードされたエントリに対応。
"mozillaNickname" エントリに対応。
cn エントリが存在する場合は表示名に使用するようにした。
diff --git a/libsylph/codeconv.c b/libsylph/codeconv.c
index 981ca7f2..dc071dad 100644
--- a/libsylph/codeconv.c
+++ b/libsylph/codeconv.c
@@ -108,6 +108,10 @@ typedef enum
#define isutf8_3_2(c) \
(((c) & 0xc0) == 0x80)
+#define isutf8bom(s) \
+ (((*(s)) & 0xff) == 0xef && ((*(s + 1)) & 0xff) == 0xbb && \
+ ((*(s + 2)) & 0xff) == 0xbf)
+
#define K_IN() \
if (state != JIS_KANJI) { \
*out++ = ESC; \
@@ -831,6 +835,12 @@ static gchar *conv_anytoutf8(const gchar *inbuf, gint *error)
return conv_sjistoutf8(inbuf, error);
case C_EUC_JP:
return conv_euctoutf8(inbuf, error);
+ case C_UTF_8:
+ if (error)
+ *error = 0;
+ if (isutf8bom(inbuf))
+ inbuf += 3;
+ return g_strdup(inbuf);
default:
if (error)
*error = 0;
@@ -864,6 +874,8 @@ static gchar *conv_utf8tosjis(const gchar *inbuf, gint *error)
}
}
+ if (isutf8bom(inbuf))
+ inbuf += 3;
return conv_iconv_strdup_with_cd(inbuf, cd, error);
}
@@ -893,6 +905,8 @@ static gchar *conv_utf8toeuc(const gchar *inbuf, gint *error)
}
}
+ if (isutf8bom(inbuf))
+ inbuf += 3;
return conv_iconv_strdup_with_cd(inbuf, cd, error);
}
@@ -1217,6 +1231,8 @@ gchar *conv_utf8todisp(const gchar *inbuf, gint *error)
if (g_utf8_validate(inbuf, -1, NULL) == TRUE) {
if (error)
*error = 0;
+ if (isutf8bom(inbuf))
+ inbuf += 3;
return g_strdup(inbuf);
} else
return conv_ustodisp(inbuf, error);
diff --git a/src/compose.c b/src/compose.c
index 65c713cc..7c4d8210 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -1900,7 +1900,7 @@ static void compose_insert_file(Compose *compose, const gchar *file,
gint error = 0;
if (enc == C_UTF_8) {
- str = g_strdup(buf);
+ str = conv_utf8todisp(buf, NULL);
} else {
str = conv_codeset_strdup_full(buf, cur_encoding,
CS_INTERNAL, &error);