aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codeconv.c38
-rw-r--r--src/codeconv.h13
-rw-r--r--src/compose.c2
-rw-r--r--src/mainwindow.c2
-rw-r--r--src/messageview.c2
-rw-r--r--src/prefs_common.c1
6 files changed, 42 insertions, 16 deletions
diff --git a/src/codeconv.c b/src/codeconv.c
index cf6021d6..18fed44d 100644
--- a/src/codeconv.c
+++ b/src/codeconv.c
@@ -885,11 +885,25 @@ static gchar *conv_noconv(const gchar *inbuf, gint *error)
return g_strdup(inbuf);
}
+static const gchar *
+conv_get_fallback_for_private_encoding(const gchar *encoding)
+{
+ if (encoding && (encoding[0] == 'X' || encoding[0] == 'x') &&
+ encoding[1] == '-') {
+ if (!g_strcasecmp(encoding, CS_X_GBK))
+ return CS_GBK;
+ }
+
+ return encoding;
+}
+
CodeConverter *conv_code_converter_new(const gchar *src_encoding,
const gchar *dest_encoding)
{
CodeConverter *conv;
+ src_encoding = conv_get_fallback_for_private_encoding(src_encoding);
+
conv = g_new0(CodeConverter, 1);
conv->code_conv_func =
conv_get_code_conv_func(src_encoding, dest_encoding);
@@ -916,39 +930,42 @@ gchar *conv_convert(CodeConverter *conv, const gchar *inbuf)
}
gchar *conv_codeset_strdup_full(const gchar *inbuf,
- const gchar *src_code, const gchar *dest_code,
+ const gchar *src_encoding,
+ const gchar *dest_encoding,
gint *error)
{
CodeConvFunc conv_func;
- conv_func = conv_get_code_conv_func(src_code, dest_code);
+ src_encoding = conv_get_fallback_for_private_encoding(src_encoding);
+
+ conv_func = conv_get_code_conv_func(src_encoding, dest_encoding);
if (conv_func != conv_noconv)
return conv_func(inbuf, error);
- return conv_iconv_strdup(inbuf, src_code, dest_code, error);
+ return conv_iconv_strdup(inbuf, src_encoding, dest_encoding, error);
}
-CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
- const gchar *dest_charset_str)
+CodeConvFunc conv_get_code_conv_func(const gchar *src_encoding,
+ const gchar *dest_encoding)
{
CodeConvFunc code_conv = conv_noconv;
CharSet src_charset;
CharSet dest_charset;
- if (!src_charset_str)
+ if (!src_encoding)
src_charset = conv_get_locale_charset();
else
- src_charset = conv_get_charset_from_str(src_charset_str);
+ src_charset = conv_get_charset_from_str(src_encoding);
/* auto detection mode */
- if (!src_charset_str && !dest_charset_str) {
+ if (!src_encoding && !dest_encoding) {
if (src_charset == C_EUC_JP || src_charset == C_SHIFT_JIS)
return conv_anytodisp;
else
return conv_noconv;
}
- dest_charset = conv_get_charset_from_str(dest_charset_str);
+ dest_charset = conv_get_charset_from_str(dest_encoding);
if (dest_charset == C_US_ASCII)
return conv_ustodisp;
@@ -1201,7 +1218,7 @@ static const struct {
{"ko_KR.EUC-KR" , C_EUC_KR , C_EUC_KR},
{"ko_KR" , C_EUC_KR , C_EUC_KR},
{"zh_CN.GB2312" , C_GB2312 , C_GB2312},
- {"zh_CN.GBK" , C_GBK , C_GB2312},
+ {"zh_CN.GBK" , C_GBK , C_GBK},
{"zh_CN" , C_GB2312 , C_GB2312},
{"zh_HK" , C_BIG5_HKSCS , C_BIG5_HKSCS},
{"zh_TW.eucTW" , C_EUC_TW , C_BIG5},
@@ -1560,6 +1577,7 @@ gboolean conv_is_multibyte_encoding(CharSet encoding)
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:
diff --git a/src/codeconv.h b/src/codeconv.h
index 44a4976f..c17cd84c 100644
--- a/src/codeconv.h
+++ b/src/codeconv.h
@@ -158,6 +158,7 @@ struct _CodeConverter
#define CS_EUC_CN "EUC-CN"
#define CS_GB2312 "GB2312"
#define CS_GBK "GBK"
+#define CS_X_GBK "X-GBK"
#define CS_EUC_TW "EUC-TW"
#define CS_BIG5 "Big5"
#define CS_BIG5_HKSCS "BIG5-HKSCS"
@@ -188,16 +189,16 @@ gchar *conv_convert (CodeConverter *conv,
(conv_codeset_strdup_full(inbuf, src_code, dest_code, NULL))
gchar *conv_codeset_strdup_full (const gchar *inbuf,
- const gchar *src_code,
- const gchar *dest_code,
+ const gchar *src_encoding,
+ const gchar *dest_encoding,
gint *error);
-CodeConvFunc conv_get_code_conv_func (const gchar *src_charset_str,
- const gchar *dest_charset_str);
+CodeConvFunc conv_get_code_conv_func (const gchar *src_encoding,
+ const gchar *dest_encoding);
gchar *conv_iconv_strdup (const gchar *inbuf,
- const gchar *src_code,
- const gchar *dest_code,
+ const gchar *src_encoding,
+ const gchar *dest_encoding,
gint *error);
gchar *conv_iconv_strdup_with_cd (const gchar *inbuf,
iconv_t cd,
diff --git a/src/compose.c b/src/compose.c
index b685386b..1e864ddd 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -647,6 +647,8 @@ static GtkItemFactoryEntry compose_entries[] =
{N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
ENC_ACTION(C_GB2312)},
+ {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
+ ENC_ACTION(C_GBK)},
{N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
ENC_ACTION(C_BIG5)},
{N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 7675b758..d785a309 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -625,6 +625,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
{N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
ENC_ACTION(C_GB2312)},
+ {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
+ ENC_ACTION(C_GBK)},
{N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
ENC_ACTION(C_BIG5)},
{N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
diff --git a/src/messageview.c b/src/messageview.c
index 9c01b036..f06d7062 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -200,6 +200,8 @@ static GtkItemFactoryEntry msgview_entries[] =
ENC_SEPARATOR,
{N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
ENC_ACTION(C_GB2312)},
+ {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
+ ENC_ACTION(C_GBK)},
{N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
ENC_ACTION(C_BIG5)},
{N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
diff --git a/src/prefs_common.c b/src/prefs_common.c
index 372ac3d3..7197142b 100644
--- a/src/prefs_common.c
+++ b/src/prefs_common.c
@@ -1159,6 +1159,7 @@ static void prefs_send_create(void)
#endif /* 0 */
SET_MENUITEM(NULL, NULL);
SET_MENUITEM(_("Simplified Chinese (GB2312)"), CS_GB2312);
+ SET_MENUITEM(_("Simplified Chinese (GBK)"), CS_GBK);
SET_MENUITEM(_("Traditional Chinese (Big5)"), CS_BIG5);
#if 0
SET_MENUITEM(_("Traditional Chinese (EUC-TW)"), CS_EUC_TW);