Am Donnerstag, den 06.03.2008, 06:24 +0100 schrieb Daniel Leidert:

[markup in console output]
> I have written s small patch based on pango_parse_markup (). It outputs
> UTF-8 string without markup and entities are replaced too. The
> differences in output are shown in the following diff:
[..]
> A problem that is left is, that the filling-stuff doesn't fully work for
> special characters with UTF-8 output. Maybe you have some idea.

Found it. Needed to replace strlen with g_utf8_strlen and then it works.
The attached patch works for me - tested on an xterm with de_DE.UTF-8.

Regards, Daniel
--- gperiodic-2.0.10.orig/gperiodic.c
+++ gperiodic-2.0.10/gperiodic.c
@@ -66,15 +66,18 @@
 void gpparse_print_element_data_for_num(int num)
 {
     int row, n, i;
+    char *escaped_header, *escaped_info;
     char fillout[HEADERTEXTLEN];
 
     printf("\n");
     for (row = 0; row < MAX_INFO_NR; row++) {
-	n = strlen(header.info[row]);
+	pango_parse_markup (header.info[row], -1, 0, NULL, &escaped_header, NULL, NULL);
+	pango_parse_markup (table[num-1].info[row], -1, 0, NULL, &escaped_info, NULL, NULL);
+	n = g_utf8_strlen(escaped_header, HEADERTEXTLEN);
 	n = HEADERTEXTLEN - n;
 	for (i=0;i<HEADERTEXTLEN;i++) fillout[i] = ' ';
 	fillout[n] = (char) NULL;
-	printf(" %s%s%s\n", header.info[row], fillout,  table[num-1].info[row]);
+	printf(" %s%s%s\n", escaped_header, fillout, escaped_info);
     }
     printf("\n");
 }

Reply via email to