From 5868adac7501134a8cb9d2ace1ae12622368a910 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 27 May 2007 20:35:32 +0000 Subject: [PATCH] correctly handle UTF-8 input text in the text info dialog (Fixes bug 2007-05-27 Lucas Rocha * src/text.c: correctly handle UTF-8 input text in the text info dialog (Fixes bug #407275). svn path=/trunk/; revision=1220 --- ChangeLog | 5 +++++ src/text.c | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 448d8a7..d577b51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-05-27 Lucas Rocha + + * src/text.c: correctly handle UTF-8 input text in the text info + dialog (Fixes bug #407275). + 2007-05-27 Lucas Rocha * src/main.c: initialize GTK+ before parsing command line options to diff --git a/src/text.c b/src/text.c index b781682..a8da744 100644 --- a/src/text.c +++ b/src/text.c @@ -74,9 +74,14 @@ zenity_text_handle_stdin (GIOChannel *channel, gsize utflen; gtk_text_buffer_get_end_iter (buffer, &end); - utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); - gtk_text_buffer_insert (buffer, &end, utftext, utflen); - g_free (utftext); + + if (!g_utf8_validate (buf, len, NULL)) { + utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); + gtk_text_buffer_insert (buffer, &end, utftext, utflen); + g_free (utftext); + } else { + gtk_text_buffer_insert (buffer, &end, buf, len); + } } }