diff --git a/src/charset.c b/src/charset.c
index 42c0e60347432c2f909d97a207c4599cf741797c..ccfac0ef86a454c339c2b7479c4eb801e1648fbf 100644 (file)
--- a/src/charset.c
+++ b/src/charset.c
#include <string.h>
#include <glib.h>
+#ifdef HAVE_LOCALE_H
static bool noconvert = true;
static const char *charset;
{
noconvert = g_get_charset(&charset);
return charset;
+ return NULL;
}
+#endif
unsigned
utf8_width(const char *str)
{
assert(str != NULL);
+#ifdef HAVE_LOCALE_H
if (g_utf8_validate(str, -1, NULL)) {
size_t len = g_utf8_strlen(str, -1);
unsigned width = 0;
return width;
} else
+#endif
return strlen(str);
}
char *
utf8_to_locale(const char *utf8str)
{
+#ifdef HAVE_LOCALE_H
gchar *str;
GError *error;
if (noconvert)
return g_strdup(utf8str);
- str = g_convert_with_fallback(utf8str, strlen(utf8str),
+ str = g_convert_with_fallback(utf8str, -1,
charset, "utf-8",
NULL, NULL, NULL,
&error);
}
return str;
+#else
+ return g_strdup(utf8str);
+#endif
}
char *
locale_to_utf8(const char *localestr)
{
+#ifdef HAVE_LOCALE_H
gchar *str;
GError *error;
if (noconvert)
return g_strdup(localestr);
- str = g_convert_with_fallback(localestr, strlen(localestr),
+ str = g_convert_with_fallback(localestr, -1,
"utf-8", charset,
NULL, NULL, NULL,
&error);
}
return str;
+#else
+ return g_strdup(localestr);
+#endif
}