[gnucash-de] Falsche Darstellung von Umlauten im Buchungstext

tadomeit tadomeit at compuserve.de
Son Mar 20 14:45:19 EST 2005


Hallo Christian,

vielen Dank für den schnellen Patch!
Ein erster Test war erfolgreich: Ich habe eine Buchung mit verstümmeltem 
Umlaut gelöscht und erneut über die HBCI-Kontenabfrage abgerufen. Die 
Darstellung ist jetzt korrekt :-) .

Viele Grüße
Thomas


Christian Stimming wrote:
> Hallo Thomas,
> 
> vielen Dank nochmal für die genaue Beschreibung. Ich hab nun die korrekte 
> Konvertierung von den utf-8 Texten in die interne gnucash-Encoding mit 
> eingebaut. Das ist nun im CVS und anhängend ist ein patch dafür. Wenn du das 
> also bei dir ausprobieren/korrigieren möchtest, dann geh in deinem 
> gnucash-Tarball und mach
> 
>   cd src/import-export/hbci
>   patch -p0 < description-utf8.diff
> 
> Anschließend gnucash übersetzen und installieren und dann sollten die Umlaute 
> hoffentlich richtig in gnucash ankommen... kannst du berichten, wie es läuft? 
> Das wär gut, weil wie gesagt meine Bank schickt mir gar keine Umlaute :-)
> 
> Gruß
> 
> Christian
> 
> Am Mittwoch, 16. März 2005 21:31 schrieb tadomeit:
> 
>>Hallo Christian,
>>
>>in der Logdatei sieht es noch gut aus.
>>Beispiel für "ß" in WEIßENSEE
>>
>> > hexdump -C 20050310-213851-1.log|grep -A1 PANK
>>
>>000067f0
>>   32 46 49 4e 41 4e 5a 41  4d 54 20 50 41 4e 4b 2e  |2FINANZAMT PANK.|
>>00006800
>>   2f 57 45 49 df 45 4e 53  45 45 0d 0a 3a 36 31 3a  |/WEIßENSEE..:61:|
>>
>>Im Kontobuch wird daraus (das Leerzeichen ist als kleines Quadrat zu
>>sehen): PANK./WEIÃ NSEE
>>
>>In einem anderen Datensatz wird aus KÖP -> KÃ P
>>
>>
>>------------------------------------------------------------------------
>>
>>Index: gnc-hbci-utils.c
>>===================================================================
>>RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-utils.c,v
>>retrieving revision 1.23.2.15
>>diff -u -r1.23.2.15 gnc-hbci-utils.c
>>--- gnc-hbci-utils.c	29 Jan 2005 12:31:22 -0000	1.23.2.15
>>+++ gnc-hbci-utils.c	19 Mar 2005 08:51:42 -0000
>>@@ -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 @@
>>   }
>> }
>> 
>>+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 *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 @@
>>        g_strdup (h_descr) : 
>>        g_strdup (_("Unspecified")));
>> 
>>+  iconv_close(cb_object.gnc_iconv_handler);
>>   free (h_descr);
>>   free (othername);
>>   return g_descr;