aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-06 09:20:42 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-06 09:20:42 +0000
commite2cbc91110f087e20502cc46c79cdd1131759d07 (patch)
treee9788c9e2d58253b23cd2107eead3929508899f0
parentbd8ad2ad3f679677771a6a94d8214fc5427a03f1 (diff)
fixed import of CSV in locale encoding.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1601 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog4
-rw-r--r--ChangeLog.ja4
-rw-r--r--src/importcsv.c17
3 files changed, 22 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 20668968..a64eef18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2007-04-06
+ * src/importcsv.c: fixed import of locale encoding.
+
+2007-04-06
+
* src/importcsv.[ch]
src/addressbook.c
src/Makefile.am: implemented CSV import (in progress).
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 0901c1de..63de59d3 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,9 @@
2007-04-06
+ * src/importcsv.c: ロケールエンコーディングのインポートを修正。
+
+2007-04-06
+
* src/importcsv.[ch]
src/addressbook.c: CSV のインポートを実装(途中)。
diff --git a/src/importcsv.c b/src/importcsv.c
index 7768f3a4..7fa0beb7 100644
--- a/src/importcsv.c
+++ b/src/importcsv.c
@@ -202,6 +202,7 @@ static void imp_csv_load_fields( gchar *sFile ) {
str = conv_localetodisp(buf, NULL);
g_print("%s\n", str);
strv = g_strsplit(str, ",", 0);
+
for (i = 0; strv[i] != NULL; i++) {
text[ FIELD_COL_SELECT ] = "";
text[ FIELD_COL_FIELD ] = strv[i];
@@ -209,8 +210,8 @@ static void imp_csv_load_fields( gchar *sFile ) {
i < N_CSV_ATTRIB ? gettext(imp_csv_attrib[i].name) : "";
gtk_clist_append( clist, text );
}
- g_free(str);
g_strfreev(strv);
+ g_free(str);
break;
}
@@ -232,6 +233,7 @@ static gint imp_csv_import_data( gchar *csvFile, AddressCache *cache ) {
gchar buf[BUFFSIZE];
gint i;
gchar **strv;
+ CharSet enc;
gchar *firstName = NULL;
gchar *lastName = NULL;
gchar *fullName = NULL;
@@ -246,14 +248,22 @@ static gint imp_csv_import_data( gchar *csvFile, AddressCache *cache ) {
addrcache_clear( cache );
cache->dataRead = FALSE;
+ enc = conv_check_file_encoding(csvFile);
+
if ((fp = g_fopen(csvFile, "rb")) == NULL) {
return;
}
while (fgets(buf, sizeof(buf), fp) != NULL) {
+ gchar *str;
+
strretchomp(buf);
- g_print("%s\n", buf);
- strv = g_strsplit(buf, ",", 0);
+ if (enc == C_UTF_8)
+ str = g_strdup(buf);
+ else
+ str = conv_localetodisp(buf, NULL);
+ g_print("%s\n", str);
+ strv = g_strsplit(str, ",", 0);
for (i = 0; strv[i] != NULL; i++) {
if (i == imp_csv_attrib[ATTR_FIRST_NAME].col)
@@ -285,6 +295,7 @@ static gint imp_csv_import_data( gchar *csvFile, AddressCache *cache ) {
firstName = lastName = fullName = nickName = address = NULL;
g_strfreev(strv);
+ g_free(str);
count++;
}