From 49160269b97a2486bd54a28469751711531dbecb Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Mon, 6 Feb 2006 18:39:19 +0000 Subject: [PATCH] Added conversion from utf8 --- gnoemoe/gm-support.c | 20 ++++++++++++++++---- gnoemoe/gm-support.h | 7 +++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gnoemoe/gm-support.c b/gnoemoe/gm-support.c index 71001dc..bb1e0f5 100644 --- a/gnoemoe/gm-support.c +++ b/gnoemoe/gm-support.c @@ -570,17 +570,17 @@ gm_notebook_focus_from_label(GtkNotebook *note, gchar *caption) { } gchar * -gm_to_utf8_with_fallback(gchar const *text, gssize len, gchar const *from, - gchar const *fallback) { +gm_convert_with_fallback(gchar const *text, gssize len, gchar const *from, + gchar const *to, gchar const *fallback) { gchar *res; gsize read, written; GString *str = g_string_new(""); // TODO: use g_iconv instead of g_convert - while ((res = g_convert(text, len, "UTF-8", from, &read, &written, NULL)) + while ((res = g_convert(text, len, to, from, &read, &written, NULL)) == NULL) { - res = g_convert(text, read, "UTF-8", from, NULL, NULL, NULL); + res = g_convert(text, read, to, from, NULL, NULL, NULL); str = g_string_append(str, res); str = g_string_append(str, fallback); @@ -598,6 +598,18 @@ gm_to_utf8_with_fallback(gchar const *text, gssize len, gchar const *from, return res; } +gchar * +gm_from_utf8_with_fallback(gchar const *text, gssize len, gchar const *to, + gchar const *fallback) { + return gm_convert_with_fallback(text, len, "UTF-8", to, fallback); +} + +gchar * +gm_to_utf8_with_fallback(gchar const *text, gssize len, gchar const *from, + gchar const *fallback) { + return gm_convert_with_fallback(text, len, from, "UTF-8", fallback); +} + GtkWidget * gm_container_item(GtkContainer *cnt, GType type) { GList *child_first = gtk_container_get_children(cnt); diff --git a/gnoemoe/gm-support.h b/gnoemoe/gm-support.h index a6e9133..e199797 100644 --- a/gnoemoe/gm-support.h +++ b/gnoemoe/gm-support.h @@ -147,8 +147,11 @@ void gm_widget_destroy_data(GtkWidget *caller, GtkWidget *destroyer); const gchar *gm_default_charset(); void gm_notebook_focus_from_label(GtkNotebook *note, gchar *caption); -gchar *gm_to_utf8_with_fallback(gchar const *text, gssize len, gchar const *from, - gchar const *fallback); +gchar *gm_from_utf8_with_fallback(gchar const *text, gssize len, + gchar const *to, gchar const *fallback); +gchar *gm_to_utf8_with_fallback(gchar const *text, gssize len, + gchar const *from, gchar const *fallback); + GtkWidget *gm_container_item(GtkContainer *cnt, GType type); #endif /* __GM_SUPPORT_H__ */