SF.net SVN: geany:[5607] trunk
colombanw at users.sourceforge.net
colombanw at xxxxx
Fri Mar 18 15:57:15 UTC 2011
Revision: 5607
http://geany.svn.sourceforge.net/geany/?rev=5607&view=rev
Author: colombanw
Date: 2011-03-18 15:57:15 +0000 (Fri, 18 Mar 2011)
Log Message:
-----------
Properly convert template files to UTF-8 on loading
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/templates.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-03-18 15:57:02 UTC (rev 5606)
+++ trunk/ChangeLog 2011-03-18 15:57:15 UTC (rev 5607)
@@ -3,6 +3,9 @@
* src/document.c, src/encodings.c, src/encodings.h:
Move document encoding conversion with BOM support to encodings.[ch] as
encodings_convert_to_utf8_auto().
+ * src/templates.c:
+ Properly convert template files to UTF-8 on loading, fixing encoding
+ issues if templates files are not encoded in UTF-8.
2011-03-18 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c 2011-03-18 15:57:02 UTC (rev 5606)
+++ trunk/src/templates.c 2011-03-18 15:57:15 UTC (rev 5607)
@@ -35,6 +35,7 @@
#include "support.h"
#include "utils.h"
#include "document.h"
+#include "encodings.h"
#include "editor.h"
#include "filetypes.h"
#include "ui_utils.h"
@@ -73,11 +74,22 @@
static gchar *read_file(const gchar *locale_fname)
{
gchar *contents;
+ gsize length;
GString *str;
- if (!g_file_get_contents(locale_fname, &contents, NULL, NULL))
+ if (! g_file_get_contents(locale_fname, &contents, &length, NULL))
return NULL;
+ if (! encodings_convert_to_utf8_auto(&contents, &length, NULL, NULL, NULL, NULL))
+ {
+ gchar *utf8_fname = utils_get_utf8_from_locale(locale_fname);
+
+ ui_set_statusbar(TRUE, _("Failed to convert template file \"%s\" to UTF-8"), utf8_fname);
+ g_free(utf8_fname);
+ g_free(contents);
+ return FALSE;
+ }
+
str = g_string_new(contents);
g_free(contents);
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