Tue Apr 16 12:58:12 CEST 2002 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / io-layer / unicode.c
1 #include <config.h>
2 #include <glib.h>
3 #include <pthread.h>
4 #include <iconv.h>
5 #include <errno.h>
6
7 #include "mono/io-layer/wapi.h"
8 #include "unicode.h"
9
10 /* This is a nasty kludge */
11 static guint32 
12 unicode_len (const gunichar2 *str)
13 {
14         guint32 len = 0;
15         
16         do {
17                 if (str [len] == '\0')
18                         return len * 2;
19
20                 len++;
21         } while (1);
22 }
23
24 gchar *_wapi_unicode_to_utf8(const gunichar2 *uni)
25 {
26         GError *error = NULL;
27         gchar *res;
28         int len;
29
30         len = unicode_len(uni);
31         
32         res = g_utf16_to_utf8 (uni, len, NULL, NULL, &error);
33
34         g_assert (!error);
35
36         return res;
37 }