aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/html.cc7
-rw-r--r--src/utf8.cc34
-rw-r--r--src/utf8.hh16
4 files changed, 55 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c8fc1db6..e71c4aa9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -53,6 +53,8 @@ dillo_SOURCES = \
klist.h \
chain.c \
chain.h \
+ utf8.cc \
+ utf8.hh \
timeout.cc \
timeout.hh \
dialog.cc \
diff --git a/src/html.cc b/src/html.cc
index 974b914c..3791a1e4 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -23,12 +23,11 @@
#include <math.h> /* for rint */
#include <errno.h>
-#include <fltk/utf.h> /* for utf8encode */
-
#include "bw.h" /* for BrowserWindow */
#include "msg.h"
#include "binaryconst.h"
#include "colors.h"
+#include "utf8.hh"
#include "misc.h"
#include "uicmd.hh"
@@ -1028,7 +1027,7 @@ char *a_Html_parse_entities(DilloHtml *html, const char *token, int toksize)
toksize-i, &entsize)) >= 0) {
if (isocode >= 128) {
/* multibyte encoding */
- n = utf8encode(isocode, buf);
+ n = a_Utf8_encode(isocode, buf);
for (k = 0; k < n; ++k)
new_str[j++] = buf[k];
} else {
@@ -3568,7 +3567,7 @@ static const char *Html_get_attr2(DilloHtml *html,
tagsize-i, &entsize)) >= 0) {
if (isocode >= 128) {
char buf[4];
- int k, n = utf8encode(isocode, buf);
+ int k, n = a_Utf8_encode(isocode, buf);
for (k = 0; k < n; ++k)
dStr_append_c(Buf, buf[k]);
} else {
diff --git a/src/utf8.cc b/src/utf8.cc
new file mode 100644
index 00000000..76a752c9
--- /dev/null
+++ b/src/utf8.cc
@@ -0,0 +1,34 @@
+/*
+ * File: utf8.c
+ *
+ * Copyright (C) 2009 Jorge Arellano Cid <jcid@dillo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <fltk/utf.h>
+
+#include "utf8.hh"
+
+// C++ functions with C linkage ----------------------------------------------
+
+/*
+ * Write UTF-8 encoding of ucs into buf and return number of bytes written.
+ */
+int a_Utf8_encode(unsigned int ucs, char *buf)
+{
+ return utf8encode(ucs, buf);
+}
+
+/*
+ * Examine first srclen bytes of src.
+ * Return 0 if not legal UTF-8, 1 if all ASCII, 2 if all below 0x800,
+ * 3 if all below 0x10000, and 4 otherwise.
+ */
+int a_Utf8_test(const char* src, unsigned int srclen)
+{
+ return utf8test(src, srclen);
+}
diff --git a/src/utf8.hh b/src/utf8.hh
new file mode 100644
index 00000000..f4d4bced
--- /dev/null
+++ b/src/utf8.hh
@@ -0,0 +1,16 @@
+#ifndef __UTF8_HH__
+#define __UTF8_HH__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+int a_Utf8_encode(unsigned int ucs, char *buf);
+int a_Utf8_test(const char* src, unsigned int srclen);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __UTF8_HH__ */
+