mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix character encodings of imported transactions.
2005-03-19 Christian Stimming <stimming@tuhh.de> * src/import-export/hbci/gnc-hbci-utils.c (gnc_hbci_descr_tognc): Correctly convert imported transaction description from utf-8 to iso-8859-15 which currently comes closest to gnucash's internal encoding. This needs to be changed again for the gnome2 port, but I'll think of that early enough. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10935 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
2e0bd8d8a0
commit
ba04a3577e
@ -1,3 +1,11 @@
|
||||
2005-03-19 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/import-export/hbci/gnc-hbci-utils.c (gnc_hbci_descr_tognc):
|
||||
Correctly convert imported transaction description from utf-8 to
|
||||
iso-8859-15 which currently comes closest to gnucash's internal
|
||||
encoding. This needs to be changed again for the gnome2 port, but
|
||||
I'll think of that early enough.
|
||||
|
||||
2005-03-13 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/import-export/hbci/gnc-hbci-getbalance.c: Improve user
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <gnome.h>
|
||||
#include <errno.h>
|
||||
#include <iconv.h>
|
||||
#include <gwenhywfar/directory.h>
|
||||
|
||||
#include "gnc-ui.h"
|
||||
@ -475,16 +476,30 @@ gnc_AB_BANKING_execute (GtkWidget *parent, AB_BANKING *api,
|
||||
}
|
||||
}
|
||||
|
||||
struct cb_struct {
|
||||
gchar **result;
|
||||
iconv_t gnc_iconv_handler;
|
||||
};
|
||||
|
||||
/* Needed for the gnc_hbci_descr_tognc and gnc_hbci_memo_tognc. */
|
||||
static void *gnc_list_string_cb (const char *string, void *user_data)
|
||||
{
|
||||
gchar **res = user_data;
|
||||
gchar *tmp1, *tmp2;
|
||||
struct cb_struct *u = user_data;
|
||||
gchar **res = u->result;
|
||||
gchar *tmp1, *tmp2, *outbuffer;
|
||||
char *inbuffer = (char*)string;
|
||||
size_t inbytes = strlen(string), outbytes = inbytes+2;
|
||||
|
||||
if (!string) return NULL;
|
||||
tmp1 = g_strdup (string);
|
||||
g_strstrip (tmp1);
|
||||
tmp1 = g_strndup (string, outbytes);
|
||||
outbuffer = tmp1;
|
||||
|
||||
iconv(u->gnc_iconv_handler, &inbuffer, &inbytes,
|
||||
&outbuffer, &outbytes);
|
||||
if (outbytes > 0)
|
||||
*outbuffer = '\0';
|
||||
|
||||
g_strstrip (tmp1);
|
||||
if (strlen (tmp1) > 0) {
|
||||
if (*res != NULL) {
|
||||
/* The " " is the separating string in between each two strings. */
|
||||
@ -511,19 +526,30 @@ char *gnc_hbci_descr_tognc (const AB_TRANSACTION *h_trans)
|
||||
char *g_descr;
|
||||
const GWEN_STRINGLIST *h_purpose = AB_Transaction_GetPurpose (h_trans);
|
||||
const GWEN_STRINGLIST *h_remotename = AB_Transaction_GetRemoteName (h_trans);
|
||||
struct cb_struct cb_object;
|
||||
|
||||
/* FIXME: The internal target encoding is hard-coded so far. This
|
||||
needs to be fixed for the gnome2 version; the target encoding is
|
||||
then probably utf-8 as well. iconv is also used in
|
||||
gnc_AB_BANKING_interactors() in hbci-interaction.c. */
|
||||
cb_object.gnc_iconv_handler = iconv_open("ISO8859-15", "UTF-8");
|
||||
g_assert(cb_object.gnc_iconv_handler != (iconv_t)(-1));
|
||||
|
||||
/* Don't use list_string_concat_delim here since we need to
|
||||
g_strstrip every single element of the string list, which is
|
||||
only done in our callback gnc_list_string_cb. The separator is
|
||||
also set there. */
|
||||
cb_object.result = &h_descr;
|
||||
if (h_purpose)
|
||||
GWEN_StringList_ForEach (h_purpose,
|
||||
&gnc_list_string_cb,
|
||||
&h_descr);
|
||||
&cb_object);
|
||||
|
||||
cb_object.result = &othername;
|
||||
if (h_remotename)
|
||||
GWEN_StringList_ForEach (h_remotename,
|
||||
&gnc_list_string_cb,
|
||||
&othername);
|
||||
&cb_object);
|
||||
/*DEBUG("HBCI Description '%s'", h_descr);*/
|
||||
|
||||
if (othername && (strlen (othername) > 0))
|
||||
@ -539,6 +565,7 @@ char *gnc_hbci_descr_tognc (const AB_TRANSACTION *h_trans)
|
||||
g_strdup (h_descr) :
|
||||
g_strdup (_("Unspecified")));
|
||||
|
||||
iconv_close(cb_object.gnc_iconv_handler);
|
||||
free (h_descr);
|
||||
free (othername);
|
||||
return g_descr;
|
||||
|
@ -54,7 +54,11 @@ GNCInteractor *gnc_AB_BANKING_interactors (AB_BANKING *api, GtkWidget *parent)
|
||||
|
||||
data = g_new0 (GNCInteractor, 1);
|
||||
data->parent = parent;
|
||||
data->gnc_iconv_handler = iconv_open("ISO8859-1", "UTF-8");
|
||||
/* FIXME: The internal target encoding is hard-coded so far. This
|
||||
needs to be fixed for the gnome2 version; the target encoding is
|
||||
then probably utf-8 as well. iconv is also used in
|
||||
gnc_hbci_descr_tognc() in gnc-hbci-utils.c. */
|
||||
data->gnc_iconv_handler = iconv_open("ISO8859-15", "UTF-8");
|
||||
g_assert(data->gnc_iconv_handler != (iconv_t)(-1));
|
||||
data->keepAlive = TRUE;
|
||||
data->cache_pin =
|
||||
|
Loading…
Reference in New Issue
Block a user