SF.net SVN: geany: [2071] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Nov 25 13:48:23 UTC 2007
Revision: 2071
http://geany.svn.sourceforge.net/geany/?rev=2071&view=rev
Author: eht16
Date: 2007-11-25 05:48:22 -0800 (Sun, 25 Nov 2007)
Log Message:
-----------
Display character which caused a failed encoding conversion when saving a file.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-11-23 16:37:03 UTC (rev 2070)
+++ trunk/ChangeLog 2007-11-25 13:48:22 UTC (rev 2071)
@@ -1,3 +1,9 @@
+2007-11-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/document.c: Display character which caused a failed encoding
+ conversion when saving a file.
+
+
2007-11-23 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/symbols.c, tagmanager/basic.c:
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2007-11-23 16:37:03 UTC (rev 2070)
+++ trunk/src/document.c 2007-11-25 13:48:22 UTC (rev 2071)
@@ -1186,20 +1186,30 @@
{
GError *conv_error = NULL;
gchar* conv_file_contents = NULL;
+ gsize bytes_read;
gsize conv_len;
// try to convert it from UTF-8 to original encoding
conv_file_contents = g_convert(data, len-1, doc_list[idx].encoding, "UTF-8",
- NULL, &conv_len, &conv_error);
+ &bytes_read, &conv_len, &conv_error);
if (conv_error != NULL)
{
+ gchar *context = NULL;
+
+ if (conv_error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE)
+ {
+ context = g_malloc(4); // read 3 bytes from Sci + '\0'
+ sci_get_text_range(doc_list[idx].sci, bytes_read, bytes_read + 3, context);
+ }
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("An error occurred while converting the file from UTF-8 in \"%s\". The file remains unsaved."
- "\nError message: %s\n"),
- doc_list[idx].encoding, conv_error->message);
- geany_debug("encoding error: %s)", conv_error->message);
+ "\nError message: %s\nThe error occurred at \"%s\"."),
+ doc_list[idx].encoding, conv_error->message,
+ (context != NULL) ? context : _("unknown"));
+ geany_debug("encoding error: %s", conv_error->message);
g_error_free(conv_error);
+ g_free(context);
g_free(data);
return FALSE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list