From 1e5061507b7c5d61b0f0152abb6faa728906a61e Mon Sep 17 00:00:00 2001 From: James Bursa Date: Wed, 11 Sep 2002 21:19:24 +0000 Subject: [project @ 2002-09-11 21:19:24 by bursa] Convert all text to iso-8859-1 (temporary fix). svn path=/import/netsurf/; revision=35 --- render/box.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'render/box.c') diff --git a/render/box.c b/render/box.c index ee9f5b1b4..2be09b223 100644 --- a/render/box.c +++ b/render/box.c @@ -1,5 +1,5 @@ /** - * $Id: box.c,v 1.13 2002/09/11 14:24:02 monkeyson Exp $ + * $Id: box.c,v 1.14 2002/09/11 21:19:24 bursa Exp $ */ #include @@ -8,6 +8,7 @@ #include #include #include "libxml/HTMLparser.h" +#include "utf-8.h" #include "netsurf/render/css.h" #include "netsurf/render/font.h" #include "netsurf/render/box.h" @@ -73,6 +74,24 @@ struct box * box_create(xmlNode * node, box_type type, struct css_style * style, return box; } + +char * tolat1(const xmlChar * s) +{ + char *d = xcalloc(strlen(s) + 1, sizeof(char)); + char *d0 = d; + unsigned int u, chars; + + while (*s != 0) { + u = sgetu8(s, &chars); + s += chars; + *d = u < 0x100 ? u : '?'; + d++; + } + *d = 0; + + return d0; +} + /** * make a box tree with style data from an xml tree * @@ -147,7 +166,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, } if (n->type == XML_TEXT_NODE) { box = box_create(n, BOX_INLINE, parent_style, href); - box->text = squash_whitespace((char *) n->content); + box->text = squash_whitespace(tolat1(n->content)); box->length = strlen(box->text); box_add_child(inline_container, box); } else { -- cgit v1.2.3