Fri May 31 16:21:54 CEST 2002 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / io-layer / unicode.c
index 7a2adfb8bcbf9d40f7d446d24ffc6a4a17f99f23..e8cca0f23487163f45d2c578a99a3fc724832efe 100644 (file)
@@ -1,27 +1,40 @@
+/*
+ * unicode.c:  unicode conversion
+ *
+ * Author:
+ *     Dick Porter (dick@ximian.com)
+ *
+ * (C) 2002 Ximian, Inc.
+ */
+
 #include <config.h>
 #include <glib.h>
 #include <pthread.h>
+#if HAVE_ICONV_H
 #include <iconv.h>
+#elif HAVE_GICONV_H
+#include <giconv.h>
+#endif
 #include <errno.h>
 
 #include "mono/io-layer/wapi.h"
 #include "unicode.h"
 
 /* This is a nasty kludge */
-static guint32 unicode_len(const guchar *str)
+static guint32 
+unicode_len (const gunichar2 *str)
 {
-       guint32 len=0;
+       guint32 len = 0;
        
        do {
-               if(str[len]=='\0' && str[len+1]=='\0') {
-                       return(len);
-               }
+               if (str [len] == '\0')
+                       return len * 2;
 
-               len+=2;
-       } while(1);
+               len++;
+       } while (1);
 }
 
-guchar *_wapi_unicode_to_utf8(const guchar *uni)
+gchar *_wapi_unicode_to_utf8(const gunichar2 *uni)
 {
        GError *error = NULL;
        gchar *res;