summaryrefslogtreecommitdiff
path: root/pango/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'pango/utils.c')
-rw-r--r--pango/utils.c53
1 files changed, 9 insertions, 44 deletions
diff --git a/pango/utils.c b/pango/utils.c
index 5a04ccc7..6f7ff8ca 100644
--- a/pango/utils.c
+++ b/pango/utils.c
@@ -153,56 +153,21 @@ _pango_utf8_to_ucs2 (const char *str, int len)
}
-#ifdef __GLIBC__
-# define UCS4_CHARSET "UNICODELITTLE"
-#else
-# if G_BYTE_ORDER == G_LITTLE_ENDIAN
-# define UCS4_CHARSET "UCS-4-LE"
-# else
-# define UCS4_CHARSET "UCS-4-BE"
-# endif
-#endif
-
GUChar4 *
_pango_utf8_to_ucs4 (const char *str, int len)
{
- iconv_t cd;
- char *outbuf, *result;
- const char *inbuf;
- size_t inbytesleft;
- size_t outbytesleft;
- gint outlen;
-
- gint count;
-
- cd = iconv_open (UCS4_CHARSET, "UTF-8");
+ GUChar4 *result;
+ int n_chars, i;
+ const char *p;
- if (cd == (iconv_t)-1)
- g_error ("No converter from UTF-8 to " UCS4_CHARSET);
-
- if (len < 0)
- len = strlen (str);
-
- outlen = unicode_strlen (str, len) * sizeof(GUChar4);
- result = g_malloc (outlen);
-
- inbuf = str;
- inbytesleft = len;
- outbuf = result;
- outbytesleft = outlen;
-
- count = iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
-
- if (count < 0 && (errno != E2BIG))
- {
- g_free (result);
- result = NULL;
- }
-
- iconv_close (cd);
+ n_chars = unicode_strlen (str, len);
+ result = g_new (GUChar4, n_chars);
- return (GUChar4 *)result;
+ p = str;
+ for (i=0; i < n_chars; i++)
+ p = unicode_get_utf8 (p, &result[i]);
+ return result;
}
/**