aboutsummaryrefslogtreecommitdiffstats
path: root/jnlib
diff options
context:
space:
mode:
Diffstat (limited to 'jnlib')
-rw-r--r--jnlib/ChangeLog4
-rw-r--r--jnlib/utf8conv.c47
-rw-r--r--jnlib/utf8conv.h10
3 files changed, 61 insertions, 0 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index bb2d06574..81f250791 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,3 +1,7 @@
+2007-06-11 Werner Koch <[email protected]>
+
+ * utf8conv.c (jnlib_iconv_open, jnlib_iconv, jnlib_iconv_close): New.
+
2007-06-06 Werner Koch <[email protected]>
* w32help.h: New.
diff --git a/jnlib/utf8conv.c b/jnlib/utf8conv.c
index 90a319984..ac0f2e2e1 100644
--- a/jnlib/utf8conv.c
+++ b/jnlib/utf8conv.c
@@ -150,6 +150,7 @@ handle_iconv_error (const char *to, const char *from, int use_fallback)
}
+
int
set_native_charset (const char *newset)
{
@@ -694,3 +695,49 @@ utf8_to_native (const char *string, size_t length, int delim)
{
return do_utf8_to_native (string, length, delim, use_iconv);
}
+
+
+
+
+/* Wrapper function for iconv_open, required for W32 as we dlopen that
+ library on that system. */
+jnlib_iconv_t
+jnlib_iconv_open (const char *tocode, const char *fromcode)
+{
+#ifdef HAVE_W32_SYSTEM
+ if (load_libiconv ())
+ return (jnlib_iconv_t)(-1);
+#endif /*HAVE_W32_SYSTEM*/
+
+ return (jnlib_iconv_t)iconv_open (tocode, fromcode);
+}
+
+
+/* Wrapper function for iconv, required for W32 as we dlopen that
+ library on that system. */
+size_t
+jnlib_iconv (jnlib_iconv_t cd,
+ const char **inbuf, size_t *inbytesleft,
+ char **outbuf, size_t *outbytesleft)
+{
+
+#ifdef HAVE_W32_SYSTEM
+ if (load_libiconv ())
+ return 0;
+#endif /*HAVE_W32_SYSTEM*/
+
+ return iconv ((iconv_t)cd, inbuf, inbytesleft, outbuf, outbytesleft);
+}
+
+/* Wrapper function for iconv_close, required for W32 as we dlopen that
+ library on that system. */
+int
+jnlib_iconv_close (jnlib_iconv_t cd)
+{
+#ifdef HAVE_W32_SYSTEM
+ if (load_libiconv ())
+ return 0;
+#endif /*HAVE_W32_SYSTEM*/
+
+ return iconv_close ((iconv_t)cd);
+}
diff --git a/jnlib/utf8conv.h b/jnlib/utf8conv.h
index 9e1ce9530..757920cac 100644
--- a/jnlib/utf8conv.h
+++ b/jnlib/utf8conv.h
@@ -30,4 +30,14 @@ char *native_to_utf8 (const char *string);
char *utf8_to_native (const char *string, size_t length, int delim);
+/* Silly wrappers, required for W32 portability. */
+typedef void *jnlib_iconv_t;
+
+jnlib_iconv_t jnlib_iconv_open (const char *tocode, const char *fromcode);
+size_t jnlib_iconv (jnlib_iconv_t cd, const char **inbuf, size_t *inbytesleft,
+ char **outbuf, size_t *outbytesleft);
+int jnlib_iconv_close (jnlib_iconv_t cd);
+
+
+
#endif /*LIBJNLIB_UTF8CONF_H*/