[gtef] FileLoader: add workaround for uchardet bug
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtef] FileLoader: add workaround for uchardet bug
- Date: Sat, 27 May 2017 15:09:22 +0000 (UTC)
commit 997216f974eeefce0c3c717e5da45921a8654133
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat May 27 16:51:22 2017 +0200
FileLoader: add workaround for uchardet bug
gtef/gtef-file-loader.c | 8 ++++++++
testsuite/test-file-loader.c | 8 ++++----
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gtef/gtef-file-loader.c b/gtef/gtef-file-loader.c
index 41d7592..765ee17 100644
--- a/gtef/gtef-file-loader.c
+++ b/gtef/gtef-file-loader.c
@@ -912,6 +912,14 @@ determine_encoding (GTask *task)
charset = uchardet_get_charset (ud);
if (charset != NULL && charset[0] != '\0')
{
+ /* Workaround for uchardet bug:
+ * https://bugs.freedesktop.org/show_bug.cgi?id=101204
+ */
+ if (g_ascii_strcasecmp (charset, "ASCII") == 0)
+ {
+ charset = "UTF-8";
+ }
+
priv->detected_encoding = gtef_encoding_new (charset);
}
diff --git a/testsuite/test-file-loader.c b/testsuite/test-file-loader.c
index e889000..913d654 100644
--- a/testsuite/test-file-loader.c
+++ b/testsuite/test-file-loader.c
@@ -289,7 +289,7 @@ test_loader_newlines (gboolean implicit_trailing_newline,
test_loader (contents,
expected_buffer_content,
0, 0,
- "ASCII",
+ "UTF-8",
expected_newline_type,
-1,
implicit_trailing_newline,
@@ -317,7 +317,7 @@ test_loader_split_cr_lf (const gchar *content,
test_loader (content,
content,
0, 0,
- "ASCII",
+ "UTF-8",
GTEF_NEWLINE_TYPE_LF,
expected_line_count,
FALSE,
@@ -417,7 +417,7 @@ test_loader_max_size (const gchar *contents,
expected_buffer_content,
expected_error_domain,
expected_error_code,
- "ASCII",
+ "UTF-8",
GTEF_NEWLINE_TYPE_LF,
-1,
FALSE,
@@ -451,7 +451,7 @@ test_max_size (void)
/* The idea of this unit test is not to test thoroughly all character encodings,
* a better place for this is uchardet. The idea is just to test something else
- * than ASCII.
+ * than ASCII/UTF-8.
*/
static void
test_encoding (void)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]