mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-01 04:59:29 -06:00
Use glib's g_iconv functions instead of the system's iconv(3)
functions to improve portability. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12198 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
051c9afeb1
commit
b12cf9b46f
@ -1,3 +1,9 @@
|
||||
2005-12-29 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/import-export/hbci/gnc-hbci-utils.h, gnc-hbci-utils.c: Use
|
||||
glib's g_iconv functions instead of the system's iconv(3)
|
||||
functions to improve portability.
|
||||
|
||||
2005-12-28 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/glib-compat.h:
|
||||
|
@ -581,9 +581,9 @@ hbci_trans_fill_values(const AB_ACCOUNT *h_acc, HBCITransDialog *td)
|
||||
to be fixed for the gnome2 version; the source encoding is then
|
||||
probably utf-8 as well. iconv is also used in
|
||||
gnc_AB_BANKING_interactors() in hbci-interaction.c. */
|
||||
iconv_t gnc_iconv_handler =
|
||||
iconv_open(gnc_hbci_AQBANKING_encoding(), gnc_hbci_book_encoding());
|
||||
g_assert(gnc_iconv_handler != (iconv_t)(-1));
|
||||
GIConv gnc_iconv_handler =
|
||||
g_iconv_open(gnc_hbci_AQBANKING_encoding(), gnc_hbci_book_encoding());
|
||||
g_assert(gnc_iconv_handler != (GIConv)(-1));
|
||||
|
||||
/* OpenHBCI newer than 0.9.8: use account's bankCode values
|
||||
* instead of the bank's ones since this is what some banks
|
||||
@ -649,7 +649,7 @@ hbci_trans_fill_values(const AB_ACCOUNT *h_acc, HBCITransDialog *td)
|
||||
AB_Transaction_SetTextKey (trans, 51);
|
||||
}
|
||||
|
||||
iconv_close(gnc_iconv_handler);
|
||||
g_iconv_close(gnc_iconv_handler);
|
||||
return trans;
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ gnc_AB_BANKING_execute (GtkWidget *parent, AB_BANKING *api,
|
||||
|
||||
struct cb_struct {
|
||||
gchar **result;
|
||||
iconv_t gnc_iconv_handler;
|
||||
GIConv gnc_iconv_handler;
|
||||
};
|
||||
|
||||
/* Needed for the gnc_hbci_descr_tognc and gnc_hbci_memo_tognc. */
|
||||
@ -540,8 +540,8 @@ char *gnc_hbci_descr_tognc (const AB_TRANSACTION *h_trans)
|
||||
struct cb_struct cb_object;
|
||||
|
||||
cb_object.gnc_iconv_handler =
|
||||
iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
|
||||
g_assert(cb_object.gnc_iconv_handler != (iconv_t)(-1));
|
||||
g_iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
|
||||
g_assert(cb_object.gnc_iconv_handler != (GIConv)(-1));
|
||||
|
||||
/* Get othername */
|
||||
cb_object.result = &othername;
|
||||
@ -564,7 +564,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);
|
||||
g_iconv_close(cb_object.gnc_iconv_handler);
|
||||
free (h_descr);
|
||||
free (othername);
|
||||
return g_descr;
|
||||
@ -579,8 +579,8 @@ char *gnc_hbci_getpurpose (const AB_TRANSACTION *h_trans)
|
||||
struct cb_struct cb_object;
|
||||
|
||||
cb_object.gnc_iconv_handler =
|
||||
iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
|
||||
g_assert(cb_object.gnc_iconv_handler != (iconv_t)(-1));
|
||||
g_iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
|
||||
g_assert(cb_object.gnc_iconv_handler != (GIConv)(-1));
|
||||
|
||||
cb_object.result = &h_descr;
|
||||
if (h_purpose)
|
||||
@ -590,7 +590,7 @@ char *gnc_hbci_getpurpose (const AB_TRANSACTION *h_trans)
|
||||
|
||||
g_descr = g_strdup (h_descr ? h_descr : "");
|
||||
|
||||
iconv_close(cb_object.gnc_iconv_handler);
|
||||
g_iconv_close(cb_object.gnc_iconv_handler);
|
||||
free (h_descr);
|
||||
return g_descr;
|
||||
}
|
||||
@ -898,19 +898,26 @@ char *gnc_AB_VALUE_toReadableString(const AB_VALUE *v)
|
||||
return g_strdup(tmp);
|
||||
}
|
||||
|
||||
/* Note: In the gnome2-branch we don't need the iconv(3) conversion
|
||||
and gnc_call_iconv() anymore since the gnc_book has an UTF-8
|
||||
encoding and the AqBanking library also expects all strings in
|
||||
UTF-8. Nevertheless we keep all these functions for now, just in
|
||||
case they might be needed later.
|
||||
*/
|
||||
|
||||
/* Returns a newly allocated gchar, converted according to the given
|
||||
handler */
|
||||
gchar *gnc_call_iconv(iconv_t handler, const char* input)
|
||||
gchar *gnc_call_iconv(GIConv handler, const gchar* input)
|
||||
{
|
||||
char *inbuffer = (char*)input;
|
||||
char *outbuffer, *outbufferstart;
|
||||
size_t inbytes, outbytes;
|
||||
gchar *inbuffer = (gchar*)input;
|
||||
gchar *outbuffer, *outbufferstart;
|
||||
gsize inbytes, outbytes;
|
||||
|
||||
inbytes = strlen(inbuffer);
|
||||
outbytes = inbytes + 2;
|
||||
outbufferstart = g_strndup(inbuffer, outbytes);
|
||||
outbuffer = outbufferstart;
|
||||
iconv(handler, &inbuffer, &inbytes, &outbuffer, &outbytes);
|
||||
g_iconv(handler, &inbuffer, &inbytes, &outbuffer, &outbytes);
|
||||
if (outbytes > 0)
|
||||
*outbuffer = '\0';
|
||||
return outbufferstart;
|
||||
|
@ -153,7 +153,7 @@ char *gnc_AB_VALUE_toReadableString(const AB_VALUE *v);
|
||||
|
||||
/** Returns a newly allocated gchar, converted according to the given
|
||||
handler */
|
||||
gchar *gnc_call_iconv(iconv_t handler, const char* input);
|
||||
gchar *gnc_call_iconv(GIConv handler, const gchar* input);
|
||||
|
||||
/** Returns the encoding of the current book in the format as required
|
||||
by iconv_open(3). */
|
||||
|
@ -60,8 +60,8 @@ GNCInteractor *gnc_AB_BANKING_interactors (AB_BANKING *api, GtkWidget *parent)
|
||||
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(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
|
||||
g_assert(data->gnc_iconv_handler != (iconv_t)(-1));
|
||||
g_iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
|
||||
g_assert(data->gnc_iconv_handler != (GIConv)(-1));
|
||||
data->keepAlive = TRUE;
|
||||
data->cache_pin =
|
||||
gnc_gconf_get_bool(GCONF_SECTION, KEY_REMEMBER_PIN, NULL);
|
||||
@ -90,7 +90,7 @@ void GNCInteractor_delete(GNCInteractor *data)
|
||||
data->dialog = NULL;
|
||||
|
||||
g_hash_table_destroy(data->showbox_hash);
|
||||
iconv_close(data->gnc_iconv_handler);
|
||||
g_iconv_close(data->gnc_iconv_handler);
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ struct _inter_data
|
||||
const char *format_pin_min_char;
|
||||
|
||||
/* The iconv handler for utf8 -> latin1 conversion */
|
||||
iconv_t gnc_iconv_handler;
|
||||
GIConv gnc_iconv_handler;
|
||||
|
||||
/* Flags to keep track on whether an HBCI action is running or
|
||||
not. */
|
||||
|
Loading…
Reference in New Issue
Block a user