From 02674693069358fc9f59700ea150d3811281f296 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Fri, 11 Apr 2003 21:06:51 +0000 Subject: [project @ 2003-04-11 21:06:51 by bursa] Memory usage and CSS fixes. svn path=/import/netsurf/; revision=122 --- utils/utils.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'utils/utils.c') diff --git a/utils/utils.c b/utils/utils.c index 47c90a4c0..a2fab4e12 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -1,11 +1,12 @@ /** - * $Id: utils.c,v 1.7 2003/04/05 21:38:06 bursa Exp $ + * $Id: utils.c,v 1.8 2003/04/11 21:06:51 bursa Exp $ */ #include #include #include #include +#include "libxml/encoding.h" #include "libxml/uri.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -98,6 +99,40 @@ char * squash_whitespace(const char * s) return c; } +char * tolat1(xmlChar * s) +{ + unsigned int length = strlen((char*) s); + char *d = xcalloc(length + 1, sizeof(char)); + char *d0 = d; + int u, chars; + + while (*s != 0) { + chars = length; + u = xmlGetUTF8Char((unsigned char *) s, &chars); + s += chars; + length -= chars; + if (u == 0x09 || u == 0x0a || u == 0x0d) + *d = ' '; + else if ((0x20 <= u && u <= 0x7f) || (0xa0 <= u && u <= 0xff)) + *d = u; + else + *d = '?'; + d++; + } + *d = 0; + + return d0; +} + +char *squash_tolat1(xmlChar *s) +{ + /* TODO: optimize */ + char *lat1 = tolat1(s); + char *squash = squash_whitespace(lat1); + free(lat1); + return squash; +} + char *url_join(const char* new, const char* base) { char* ret; -- cgit v1.2.1