]> git.pld-linux.org Git - packages/dillo.git/blame - dillo-encodings.patch
- patch by Alexey Tourbin
[packages/dillo.git] / dillo-encodings.patch
CommitLineData
020fab79 1diff -BurN dillo-0.6.6.old/Makefile.am dillo-0.6.6/Makefile.am
2--- dillo-0.6.6.old/Makefile.am Sat Jun 1 18:00:09 2002
3+++ dillo-0.6.6/Makefile.am Sat Jun 1 18:02:02 2002
4@@ -1,17 +1,21 @@
5 SUBDIRS = doc src
6
7-EXTRA_DIST = dillorc
8+EXTRA_DIST = dillorc encodings
9
10 install-data-local: dillorc
11 -if [ -d $(DESTDIR)$(sysconfdir) ]; then \
12 $(INSTALL_DATA) --backup=t $(srcdir)/dillorc $(DESTDIR)$(sysconfdir)/; \
13+ $(INSTALL_DATA) --backup=t $(srcdir)/encodings $(DESTDIR)$(sysconfdir)/; \
14 elif [ -d /etc/ ]; then \
15 $(INSTALL_DATA) --backup=t $(srcdir)/dillorc /etc/; \
16+ $(INSTALL_DATA) --backup=t $(srcdir)/encodings /etc/; \
17 fi
18
19 uninstall-local:
20 -if [ -d $(DESTDIR)$(sysconfdir) ]; then \
21 rm -f $(DESTDIR)$(sysconfdir)/dillorc*; \
22+ rm -f $(DESTDIR)$(sysconfdir)/encodings*; \
23 elif [ -d /etc/ ]; then \
24- rm -f /etc/dillorc*
25+ rm -f /etc/dillorc*; \
26+ rm -f /etc/encodings* ;\
27 fi
28diff -BurN dillo-0.6.6.old/encodings dillo-0.6.6/encodings
29--- dillo-0.6.6.old/encodings Thu Jan 1 03:00:00 1970
30+++ dillo-0.6.6/encodings Sat Jun 1 18:02:02 2002
31@@ -0,0 +1,18 @@
32+<enc value="ASCII">7-bit ASCII</enc>
33+<enc value="ISO8859-1">Western European (ISO 8859-1)</enc>
34+<enc value="ISO8859-15">Western European (ISO 8859-15)</enc>
35+<enc value="CP1252">Western European (CodePage1252)</enc>
36+<enc value="ISO8859-2">Central European (ISO 8859-2)</enc>
37+<enc value="CP1250">Central European (CodePage1250)</enc>
38+<enc value="ISO8859-3">Southern European (ISO 8859-3)</enc>
39+<enc value="KOI8-R">Cyrillic (KOI8-R)</enc>
40+<enc value="CP1251">Cyrillic (CodePage1251)</enc>
41+<enc value="IBM866">Cyrillic (IBM866)</enc>
42+<enc value="ISO8859-13">Baltic (ISO 8859-13)</enc>
43+<enc value="ISO8859-4">Baltic (ISO 8859-4)</enc>
44+<enc value="CP1257">Baltic (CodePage1257)</enc>
45+<enc value="ISO8859-10">Nordic (ISO 8859-10)</enc>
46+<enc value="ISO8859-14">Celtic (ISO 8859-14)</enc>
47+<enc value="KOI8-U">Ukraine (KOI8-U)</enc>
48+<enc value="UTF-8">Unicode (UTF-8)</enc>
49+<enc value="UTF-16">Unicode (UTF-16)</enc>
50diff -BurN dillo-0.6.6.old/src/Makefile.am dillo-0.6.6/src/Makefile.am
51--- dillo-0.6.6.old/src/Makefile.am Sat Jun 1 18:00:09 2002
52+++ dillo-0.6.6/src/Makefile.am Sat Jun 1 18:02:03 2002
53@@ -51,6 +51,9 @@
54 dw_tooltip.h \
55 dw_widget.c \
56 dw_widget.h \
57+ encodings.c \
58+ encodings.h \
59+ encoding-types.h \
60 findtext.c \
61 findtext.h \
62 web.c \
63diff -BurN dillo-0.6.6.old/src/browser.h dillo-0.6.6/src/browser.h
64--- dillo-0.6.6.old/src/browser.h Sat Jun 1 18:00:09 2002
65+++ dillo-0.6.6/src/browser.h Sat Jun 1 18:02:03 2002
66@@ -4,10 +4,8 @@
67 #include <sys/types.h>
68 #include <gdk/gdk.h>
69 #include <gtk/gtk.h>
70-
71 #include "url.h" /* for DilloUrl */
72-
73-
74+#include "encodings-types.h"
75 typedef struct _BrowserWindow BrowserWindow;
76 typedef struct _DilloMenuPopup DilloMenuPopup;
77
78@@ -58,6 +56,9 @@
79 /* The bookmarks menu so that we can add things to it. */
80 GtkWidget *bookmarks_menu;
81
82+ /* The encoding menu */
83+ GtkWidget *enc_menu;
84+
85 /* The "Headings" and "Anchors" menus */
86 GtkWidget *pagemarks_menuitem;
87 GtkWidget *pagemarks_menu;
88@@ -118,6 +119,10 @@
89
90 /* The tag for the idle function that sets button sensitivity. */
91 gint sens_idle_tag;
92+
93+ /* encodings variable */
94+ gchar* encoding; /* the selected character set (pointer to static content -don't free it*/
95+ deConversion dcv; /* handle for character set conversion */
96 };
97
98
99diff -BurN dillo-0.6.6.old/src/dillo.c dillo-0.6.6/src/dillo.c
100--- dillo-0.6.6.old/src/dillo.c Sat Jun 1 18:00:09 2002
101+++ dillo-0.6.6/src/dillo.c Sat Jun 1 18:02:03 2002
102@@ -22,6 +22,13 @@
103 #include <stdio.h>
104 #include <gtk/gtk.h>
105
106+#ifdef HAVE_LANGINFO
107+#include <langinfo.h>
108+#if ! defined(CODESET) && defined (_NL_CTYPE_CODESET_NAME)
109+#define CODESET _NL_CTYPE_CODESET_NAME
110+#endif
111+#endif
112+
113 #include <sys/types.h>
114 #include <sys/stat.h>
115 #include <string.h>
116@@ -37,6 +44,7 @@
117 #include "nav.h"
118 #include "history.h"
119 #include "bookmark.h"
120+#include "encodings.h"
121 #include "dicache.h"
122 #include "dns.h"
123 #include "IO/Url.h"
124@@ -61,6 +69,7 @@
125 {
126 gchar *file;
127 gchar *dillo_text_domain;
128+ gchar *loctmp;
129 DilloUrl *start_url;
130 BrowserWindow *bw;
131
132@@ -68,7 +77,21 @@
133 * todo: implement a cleaner mechanism (in file.c) */
134 signal(SIGPIPE, SIG_IGN);
135
136- g_print("Setting locale to %s\n", gtk_set_locale());
137+ curr_locale=gtk_set_locale();
138+#ifdef HAVE_LANGINFO
139+ curr_locale = nl_langinfo(CODESET);
140+#else
141+ loctmp = strchr(curr_locale, '.');
142+ if (loctmp != NULL) {
143+ gchar** trk = g_strsplit(++loctmp, ";", 1);
144+ curr_locale = g_strdup(trk[0]);
145+ g_strfreev(trk);
146+ } else {
147+ curr_locale = "ASCII";
148+ }
149+#endif
150+
151+ g_print("Setting locale to %s\n",curr_locale);
152
153 /* binding the textdomain for GNU gettext: should return "dillo" */
154 dillo_text_domain = textdomain("dillo");
155@@ -92,6 +115,7 @@
156 bw = a_Interface_browser_window_new(prefs.width, prefs.height);
157
158 a_Bookmarks_init();
159+ a_Encodings_init();
160
161 /* Send dillo startup screen */
162 start_url = a_Url_new("splash", "about:", 0, 0);
163diff -BurN dillo-0.6.6.old/src/dillo.h dillo-0.6.6/src/dillo.h
164--- dillo-0.6.6.old/src/dillo.h Sat Jun 1 18:00:09 2002
165+++ dillo-0.6.6/src/dillo.h Sat Jun 1 18:02:03 2002
166@@ -6,4 +6,5 @@
167
168 #define DILLO_HOME "http://dillo.cipsga.org.br/"
169
170+char* curr_locale;
171 #endif /* __DILLO_H__ */
172diff -BurN dillo-0.6.6.old/src/encodings-types.h dillo-0.6.6/src/encodings-types.h
173--- dillo-0.6.6.old/src/encodings-types.h Thu Jan 1 03:00:00 1970
174+++ dillo-0.6.6/src/encodings-types.h Sat Jun 1 18:02:03 2002
175@@ -0,0 +1,19 @@
176+#ifndef __DILLO_ENCODING_TYPES_H__
177+#define __DILLO_ENCODING_TYPES_H__
178+#include <iconv.h>
179+/* Copyright (C) 2002 Grigory Bakunov <black@asplinux.ru> */
180+
181+typedef struct _deConversion deConversion;
182+
183+struct _deConversion {
184+ iconv_t c_from;
185+ iconv_t c_to;
186+};
187+
188+
189+typedef enum {
190+ DE_DECODE,
191+ DE_ENCODE
192+} deDirection;
193+
194+#endif /* __DILLO_ENCODING_TYPES_H__ */
195diff -BurN dillo-0.6.6.old/src/encodings.c dillo-0.6.6/src/encodings.c
196--- dillo-0.6.6.old/src/encodings.c Thu Jan 1 03:00:00 1970
197+++ dillo-0.6.6/src/encodings.c Sat Jun 1 18:02:03 2002
198@@ -0,0 +1,376 @@
199+/* cruelty :) */
200+
201+/* Copyright (C) 2002 Grigory Bakunov <black@asplinux.ru> */
202+
203+/* Copyright (C) 1997 Ian Main
204+ *
205+ * This program is free software; you can redistribute it and/or modify
206+ * it under the terms of the GNU General Public License as published by
207+ * the Free Software Foundation; either version 2 of the License, or
208+ * (at your option) any later version.
209+ *
210+ * This program is distributed in the hope that it will be useful,
211+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
213+ * GNU General Public License for more details.
214+ *
215+ * You should have received a copy of the GNU General Public License
216+ * along with this program; if not, write to the Free Software
217+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
218+ */
219+
220+#include <gtk/gtk.h>
221+
222+#include <errno.h>
223+#include <stdio.h>
224+#include <stdlib.h>
225+#include <string.h>
226+
227+#include "list.h"
228+#include "interface.h"
229+#include "dillo.h"
230+#include "nav.h"
231+#include "browser.h"
232+#include "menu.h"
233+#include "misc.h"
234+#include "url.h"
235+
236+#define LOAD_ENCODINGS 1
237+#define SAVE_ENCODING 2
238+#define CLOSE_ENCODINGS 3
239+
240+/* this #define will cut page title if > 39 chars */
241+#define TITLE39
242+
243+/* double quote */
244+#define D_QUOTE 0x22
245+
246+/* Data types */
247+
248+typedef struct _Encoding Encoding;
249+typedef struct _CallbackInfo CallbackInfo;
250+
251+struct _Encoding {
252+ char *title;
253+ char *iconv_name;
254+ GtkWidget *menuitem;
255+};
256+
257+struct _CallbackInfo {
258+ BrowserWindow *bw;
259+ guint index;
260+};
261+
262+/*
263+ * Forward declarations
264+ */
265+static void
266+ Encodings_load_to_menu(FILE *fp),
267+ Encodings_file_op(gint operation, const char *title, const char *iconv_name),
268+ Encodings_save_to_file(FILE *fp, const char *title, const char *iconv_name);
269+
270+static char*
271+ Encodings_search_line(char *line, char *start_text, char *end_text);
272+
273+/*
274+ * Local data
275+ */
276+static Encoding *encodings = NULL;
277+static gint num_encodings = 0;
278+static gint num_encodings_max = 16;
279+
280+
281+/*
282+ * Allocate memory and load the encodings list
283+ */
284+void a_Encodings_init(void)
285+{
286+ gchar *file;
287+
288+ /* Here we load and set the encodings */
289+ file = a_Misc_prepend_user_home(".dillo/encodings");
290+ Encodings_file_op(LOAD_ENCODINGS, file, NULL);
291+ g_free(file);
292+}
293+
294+/*
295+ * ?
296+ */
297+void Encodings_set_encoding(GtkWidget *widget, CallbackInfo *CbInfo)
298+{
299+ if (CbInfo->index >= num_encodings) {
300+ g_warning("encoding not found!\n");
301+ return;
302+ }
303+ g_print("Selected encoding: %s\n",encodings[CbInfo->index].iconv_name);
304+ CbInfo->bw->encoding=encodings[CbInfo->index].iconv_name;
305+ a_Nav_reload(CbInfo->bw);
306+ /*HERE!!! LOOKOUT!!!! */
307+}
308+
309+/*
310+ * Add a encoding to the encodings menu of a particular browser window
311+ */
312+void Encodings_add_to_menu(BrowserWindow *bw, GtkWidget *menuitem, guint index)
313+{
314+ CallbackInfo *CbInfo;
315+
316+ gtk_menu_append(GTK_MENU(bw->enc_menu), menuitem);
317+
318+ CbInfo = g_new(CallbackInfo, 1);
319+ CbInfo->bw = bw;
320+ CbInfo->index = index;
321+
322+ /* accelerator goes here */
323+ gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
324+ (GtkSignalFunc)Encodings_set_encoding, CbInfo);
325+}
326+
327+/*
328+ * ?
329+ */
330+static GtkWidget *Encodings_insert(const char *title, const char *iconv_name)
331+{
332+ GtkWidget *menuitem;
333+
334+ menuitem = gtk_menu_item_new_with_label(title);
335+ gtk_widget_show(menuitem);
336+
337+ a_List_add(encodings, num_encodings, num_encodings_max);
338+ encodings[num_encodings].title = g_strdup(title);
339+ encodings[num_encodings].iconv_name = g_strdup(iconv_name);
340+ encodings[num_encodings].menuitem = menuitem;
341+ num_encodings++;
342+ return menuitem;
343+}
344+
345+/*
346+ * Add the new encoding to encodings menu of _all_ browser windows and then
347+ * write the new encoding to file
348+ */
349+/*
350+void a_Encodings_add(GtkWidget *widget, gpointer client_data)
351+{
352+ BrowserWindow *bw = (BrowserWindow *)client_data;
353+ gint i;
354+#ifdef TITLE39
355+ gboolean allocated = FALSE;
356+#endif
357+ char *title;
358+ char *iconv_name;
359+ GtkWidget *menuitem;
360+
361+ title = bw->menu_popup.info.title;
362+ iconv_name = bw->menu_popup.info.iconv_name;
363+
364+#ifdef TITLE39
365+ if (strlen (title) > 39) {
366+ char buf1[20];
367+ char buf2[20];
368+
369+ memcpy (buf1, title, 18);
370+ buf1[18] = '\0';
371+ strcpy (buf2, title + strlen (title) - 18);
372+ buf2[18] = '\0';
373+ title = g_strconcat (buf1, "...", buf2, NULL);
374+ allocated = TRUE;
375+ }
376+#endif
377+
378+ menuitem = Encodings_insert(title, iconv_name);
379+ Encodings_add_to_menu(browser_window[0], menuitem, num_encodings-1);
380+ for (i = 1; i < num_bw; i++) {
381+ menuitem= gtk_menu_item_new_with_label(encodings[num_encodings-1].title);
382+ gtk_widget_show(menuitem);
383+ Encodings_add_to_menu(browser_window[i], menuitem, num_encodings-1);
384+ }
385+
386+ Encodings_file_op(SAVE_ENCODING, title, iconv_name);
387+
388+#ifdef TITLE39
389+ if (allocated)
390+ g_free (title);
391+#endif
392+}
393+*/
394+/*
395+ * Never called (the file remains open all the time) --Jcid
396+ */
397+void Encodings_close(void)
398+{
399+ Encodings_file_op(CLOSE_ENCODINGS, NULL, NULL);
400+}
401+
402+/*
403+ * Performs operations on the encoding file..
404+ * for first call, title is the filename
405+ */
406+static void
407+ Encodings_file_op(gint operation, const char *title, const char *iconv_name)
408+{
409+ static FILE *fp;
410+ static gint initialized = 0;
411+
412+ if (!initialized) {
413+ if (operation == LOAD_ENCODINGS) {
414+ if ((fp = fopen(title, "a+")) == NULL)
415+ g_print("dillo: opening encoding file %s: %s\n",
416+ title, strerror(errno));
417+ else
418+ initialized = 1;
419+ } else
420+ g_print("Error: invalid call to Encodings_file_op.\n");
421+ }
422+
423+ g_return_if_fail( initialized );
424+
425+ switch (operation) {
426+ case LOAD_ENCODINGS:
427+ Encodings_load_to_menu(fp);
428+ break;
429+
430+ case SAVE_ENCODING:
431+ Encodings_save_to_file(fp, title, iconv_name);
432+ break;
433+
434+ case CLOSE_ENCODINGS:
435+ fclose(fp);
436+ break;
437+
438+ default:
439+ break;
440+ }
441+}
442+
443+/*
444+ * Save encodings to ~/.dillo/encodings
445+ */
446+static void
447+ Encodings_save_to_file(FILE *fp, const char *title, const char* iconv_name)
448+{
449+ fseek(fp, 0L, SEEK_END);
450+ fprintf(fp, "<enc value=\"%s\">%s</a>\n", iconv_name,title);
451+ fflush(fp);
452+}
453+
454+/*
455+ * Load encodings
456+ */
457+static void Encodings_load_to_menu(FILE *fp)
458+{
459+ gchar *title=NULL;
460+ gchar *iconv_name=NULL;
461+ char buf[4096];
462+ gint i = 0;
463+ GtkWidget *menuitem;
464+
465+ rewind(fp);
466+
467+ g_print("Loading encodings...\n");
468+ while (1) {
469+ /* Read a whole line from the file */
470+ if ((fgets(buf, 4096, fp)) == NULL)
471+ break;
472+
473+ /* get url from line */
474+ if ( !(iconv_name = Encodings_search_line(buf, "=\"", "\">")) )
475+ continue;
476+
477+ /* get title from line */
478+ if ( !(title = Encodings_search_line(buf, "\">", "</")) ){
479+ g_free(iconv_name);
480+ continue;
481+ }
482+ printf("%s = %s\n",title,iconv_name);
483+ menuitem = Encodings_insert(title, iconv_name);
484+ Encodings_add_to_menu(browser_window[0], menuitem, i);
485+ g_free(iconv_name);
486+ g_free(title);
487+ i++;
488+ }
489+}
490+
491+/*
492+ * Copy encodings when new browser windows are opened.
493+ * Called by 'a_Menu_mainbar_new()'
494+ */
495+void a_Encodings_fill_new_menu(BrowserWindow *bw)
496+{
497+ gint i;
498+ GtkWidget *menuitem;
499+
500+ for (i = 0; i < num_encodings; i++) {
501+ menuitem = gtk_menu_item_new_with_label(encodings[i].title);
502+ gtk_widget_show(menuitem);
503+ Encodings_add_to_menu(bw, menuitem, i);
504+ }
505+}
506+
507+static char *
508+ Encodings_search_line(char *line, char *start_text, char *end_text) {
509+ gint segment_length;
510+ char *start_index, *end_index;
511+
512+ /* if string is not found, return NULL */
513+ if ((start_index = strstr(line, start_text)) == NULL)
514+ return (NULL);
515+ if ((end_index = strstr(line, end_text)) == NULL)
516+ return (NULL);
517+
518+ /* adjustment cause strstr returns the start of the text */
519+ start_index += strlen(start_text);
520+
521+ /* find length of text segment */
522+ segment_length = end_index - start_index;
523+ return g_strndup(start_index, segment_length);
524+};
525+
526+void a_Encoding_get_conversion(BrowserWindow *bw, char* charset) {
527+ bw->dcv.c_from=iconv_open(curr_locale,charset);
528+ bw->dcv.c_to=iconv_open(charset,curr_locale);
529+ if (bw->dcv.c_from == (iconv_t)-1 || bw->dcv.c_to == (iconv_t)-1)
530+ g_warning ("could not allocate character encoding converter.");
531+ return;
532+};
533+
534+#define MAX_CHAR_SIZE 4
535+gchar *a_Encoding_translate_encoding(deConversion dcv, gchar *buf, gint bufsize,deDirection dir) {
536+ char *result, *source, *dest;
537+ size_t s_left, d_left;
538+ iconv_t conversion;
539+ if (dir==DE_DECODE)
540+ conversion=dcv.c_from;
541+ else
542+ conversion=dcv.c_to;
543+ /* no conversion is needed, or none is available */
544+ if (conversion == (iconv_t)-1)
545+ return g_strndup(buf, bufsize);
546+
547+ /* Note that for some conversions, the translated buffer can be larger
548+ * than the input buffer. This is particularly important for conversions
549+ * to UTF8 (check the unicode standard to find out the scale factor). */
550+ result = g_malloc((bufsize + 1)*MAX_CHAR_SIZE);
551+
552+ source = buf;
553+ dest = result;
554+ s_left = bufsize;
555+ d_left = bufsize*MAX_CHAR_SIZE;
556+ if (iconv(conversion, &source, &s_left, &dest, &d_left)
557+ == (size_t)-1) {
558+ g_warning ("unable to fully convert page to native character set");
559+ /* This just skips past unconvertable characters, putting "?" in the
560+ * output, then retries the conversion. This is a hack, but it seems
561+ * like the best course of action in the circumstances. */
562+ while (s_left > 0 && d_left > 0 && errno == EILSEQ) {
563+ source++;
564+ s_left--;
565+ *dest = '?';
566+ dest++;
567+ d_left--;
568+ if (s_left > 0 && d_left > 0)
569+ iconv(conversion, &source, &s_left, &dest, &d_left);
570+ }
571+ }
572+ *dest = 0; /* terminate the string */
573+ return result;
574+}
575diff -BurN dillo-0.6.6.old/src/encodings.h dillo-0.6.6/src/encodings.h
576--- dillo-0.6.6.old/src/encodings.h Thu Jan 1 03:00:00 1970
577+++ dillo-0.6.6/src/encodings.h Sat Jun 1 18:02:03 2002
578@@ -0,0 +1,18 @@
579+#ifndef __DILLO_ENCODING_H__
580+#define __DILLO_ENCODING_H__
581+#include <gtk/gtk.h>
582+#include <iconv.h>
583+#include "browser.h"
584+#include "encodings-types.h"
585+
586+
587+/* Copyright (C) 2002 Grigory Bakunov <black@asplinux.ru> */
588+
589+void a_Encodings_init();
590+void a_Encodings_add(GtkWidget *widget, gpointer client_data);
591+void a_Encodings_fill_new_menu(BrowserWindow *bw);
592+void a_Encoding_get_conversion(BrowserWindow *bw, char* charset);
593+char *a_Encoding_translate_encoding(deConversion dcv, char *buf,
594+ gint bufsize,deDirection dir);
595+
596+#endif /* __DILLO_ENCODING_H__ */
597diff -BurN dillo-0.6.6.old/src/html.c dillo-0.6.6/src/html.c
598--- dillo-0.6.6.old/src/html.c Sat Jun 1 18:00:09 2002
599+++ dillo-0.6.6/src/html.c Sat Jun 1 18:02:03 2002
600@@ -21,6 +21,7 @@
601 #include <stdlib.h>
602 #include <stdio.h> /* for sprintf */
603 #include <math.h> /* for rint */
604+#include <errno.h> /* for iconv error codes */
605
606 #include <gtk/gtk.h>
607
608@@ -47,6 +48,7 @@
609 #include "progressbar.h"
610 #include "prefs.h"
611 #include "misc.h"
612+#include "encodings.h"
613
614 //#define DEBUG_LEVEL 3
615 #include "debug.h"
616@@ -2675,7 +2677,7 @@
617 if ((form->method == DILLO_HTML_METHOD_GET) ||
618 (form->method == DILLO_HTML_METHOD_POST)) {
619 GString *DataStr = g_string_sized_new(4096);
620-
621+ GString *DataStrEnc;
622 DEBUG_MSG(3,"Html_submit_form form->action=%s\n",URL_STR_(form->action));
623
624 for (input_index = 0; input_index < form->num_inputs; input_index++) {
625@@ -2732,6 +2734,12 @@
626 break;
627 } /* switch */
628 } /* for (inputs) */
629+ DataStrEnc = g_string_new(a_Encoding_translate_encoding(html_lb->bw->dcv,
630+ DataStr -> str,
631+ DataStr -> len,
632+ DE_ENCODE));
633+ g_string_free(DataStr,TRUE);
634+ DataStr = DataStrEnc;
635
636 if ( DataStr->str[DataStr->len - 1] == '&' )
637 g_string_truncate(DataStr, DataStr->len - 1);
638@@ -3766,6 +3774,22 @@
639 Html_write(Client->CbData, Client->Buf, Client->BufSize, 0);
640 }
641
642+static void Html_set_encoding(DilloHtml *html, char *buf, gint bufsize) {
643+ /* only do _anything_ if told so */
644+ if (html->bw->encoding != NULL)
645+ a_Encoding_get_conversion(html->bw, html->bw->encoding);
646+ return;
647+}
648+
649+static char *Html_translate_encoding(DilloHtml *html, char *buf,
650+ gint bufsize) {
651+ char* result=a_Encoding_translate_encoding(html->bw->dcv,
652+ buf, bufsize,
653+ DE_DECODE);
654+ return result;
655+
656+}
657+
658 /*
659 * Here's where we parse the html and put it into the page structure.
660 * (This function is called by Html_callback whenever there's new data)
661@@ -3777,12 +3801,18 @@
662 char completestr[32];
663 gint token_start, buf_index;
664 char *buf = Buf + html->Start_Ofs;
665+ char *buf_encoded;
666 gint bufsize = BufSize - html->Start_Ofs;
667-
668+
669 g_return_if_fail ( (page = DW_PAGE (html->dw)) != NULL );
670
671 buf = g_strndup(buf, bufsize);
672
673+ Html_set_encoding(html, buf, bufsize);
674+ buf_encoded=buf;
675+ buf = Html_translate_encoding(html, buf, bufsize);
676+ g_free(buf_encoded);
677+
678 /* Now, 'buf' and 'bufsize' define a buffer aligned to start at a token
679 * boundary. Iterate through tokens until end of buffer is reached. */
680 buf_index = 0;
681diff -BurN dillo-0.6.6.old/src/interface.c dillo-0.6.6/src/interface.c
682--- dillo-0.6.6.old/src/interface.c Sat Jun 1 18:00:09 2002
683+++ dillo-0.6.6/src/interface.c Sat Jun 1 18:02:37 2002
684@@ -17,6 +17,7 @@
685 #include <sys/stat.h>
686 #include <sys/time.h>
687 #include <fcntl.h>
688+#include <iconv.h>
689
690 #include "list.h"
691 #include "dillo.h"
692@@ -765,6 +766,9 @@
693 bw->question_dialog_window = NULL;
694 bw->question_dialog_data = NULL;
695 bw->viewsource_window = NULL;
696+ bw->encoding=NULL;
697+ bw->dcv.c_from = (iconv_t)-1; /* no conversion yet */
698+ bw->dcv.c_from = (iconv_t)-1;
699
700 /* now that the bw is made, let's customize it.. */
701 Interface_browser_window_customize(bw);
702diff -BurN dillo-0.6.6.old/src/menu.c dillo-0.6.6/src/menu.c
703--- dillo-0.6.6.old/src/menu.c Sat Jun 1 18:00:09 2002
704+++ dillo-0.6.6/src/menu.c Sat Jun 1 18:02:03 2002
705@@ -31,6 +31,7 @@
706 #include "dw_page.h" /* for a_Dw_page_add_anchor */
707 #include "bookmark.h"
708 #include "interface.h"
709+#include "encodings.h"
710
711 /*
712 * Forward declarations
713@@ -121,6 +122,8 @@
714 GtkWidget *menubar;
715 GtkWidget *file_menu;
716 GtkWidget *bookmarks_menu;
717+ GtkWidget *enc_menu;
718+
719 /* GtkWidget *help_menu; */
720
721 bw->menubar = menubar = gtk_menu_bar_new();
722@@ -158,6 +161,10 @@
723 Menu_add(help_menu, "Dillo _Manual", NULL, bw,
724 a_Commands_manual_callback, bw);
725 */
726+ enc_menu = Menu_new(menubar, tiny ? "_E" : "_Encodings", FALSE, bw);
727+ bw->enc_menu = enc_menu;
728+ a_Encodings_fill_new_menu(bw);
729+
730 return menubar;
731 }
732
This page took 0.124419 seconds and 4 git commands to generate.