Added conversion from utf8

This commit is contained in:
Jesse van den Kieboom 2006-02-06 18:39:19 +00:00
parent 45e7509e96
commit 49160269b9
2 changed files with 21 additions and 6 deletions

View File

@ -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);

View File

@ -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__ */