summaryrefslogtreecommitdiff
path: root/utils/utils.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-04-11 21:06:51 +0000
committerJames Bursa <james@netsurf-browser.org>2003-04-11 21:06:51 +0000
commit02674693069358fc9f59700ea150d3811281f296 (patch)
tree7b51c457a0a3efbdc84fb00509bea02a6413d9ee /utils/utils.c
parent7c94cf8be972d6853cc15f3971bf36fe64b04d92 (diff)
downloadnetsurf-02674693069358fc9f59700ea150d3811281f296.tar.gz
netsurf-02674693069358fc9f59700ea150d3811281f296.tar.bz2
[project @ 2003-04-11 21:06:51 by bursa]
Memory usage and CSS fixes. svn path=/import/netsurf/; revision=122
Diffstat (limited to 'utils/utils.c')
-rw-r--r--utils/utils.c37
1 files changed, 36 insertions, 1 deletions
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 <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#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;