summaryrefslogtreecommitdiff
path: root/src/audacious/chardet.c
diff options
context:
space:
mode:
authorBilal Akhtar <bilalakhtar@ubuntu.com>2011-05-03 10:34:47 +0530
committerBilal Akhtar <bilalakhtar@ubuntu.com>2011-05-03 10:34:47 +0530
commit95ef69053691c5c731d0a6538de118ea52a3cd0a (patch)
tree60a79db75770323a8af7783831aad06f6aef0a01 /src/audacious/chardet.c
parent2debbc92898682dfe0c81f1ce4999175887ec922 (diff)
Imported Upstream version 2.5.0
Diffstat (limited to 'src/audacious/chardet.c')
-rw-r--r--src/audacious/chardet.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/audacious/chardet.c b/src/audacious/chardet.c
index 7723b32..9010db2 100644
--- a/src/audacious/chardet.c
+++ b/src/audacious/chardet.c
@@ -21,18 +21,31 @@
#include <libaudcore/audstrings.h>
#include "audconfig.h"
-#include "chardet.h"
#include "config.h"
#include "i18n.h"
-#include "main.h"
#include "debug.h"
#ifdef USE_CHARDET
# include <libguess.h>
#endif
-gchar *
-cd_str_to_utf8(const gchar * str)
+static gchar * cd_chardet_to_utf8 (const gchar * str, gssize len,
+ gsize * arg_bytes_read, gsize * arg_bytes_write, GError ** error);
+
+static gchar * str_to_utf8_fallback (const gchar * str)
+{
+ gchar * out = g_strconcat (str, _(" (invalid UTF-8)"), NULL);
+
+ for (gchar * c = out; * c; c ++)
+ {
+ if (* c & 0x80)
+ * c = '?';
+ }
+
+ return out;
+}
+
+static gchar * cd_str_to_utf8 (const gchar * str)
{
gchar *out_str;
@@ -78,9 +91,8 @@ cd_str_to_utf8(const gchar * str)
return str_to_utf8_fallback(str);
}
-gchar *
-cd_chardet_to_utf8(const gchar * str, gssize len, gsize * arg_bytes_read,
- gsize * arg_bytes_write, GError ** error)
+static gchar * cd_chardet_to_utf8 (const gchar * str, gssize len,
+ gsize * arg_bytes_read, gsize * arg_bytes_write, GError ** error)
{
if (error)
* error = NULL;
@@ -178,9 +190,7 @@ fallback:
return NULL; /* If we have no idea, return NULL. */
}
-
-void chardet_init(void)
+void chardet_init (void)
{
- str_to_utf8 = cd_str_to_utf8;
- chardet_to_utf8 = cd_chardet_to_utf8;
+ str_set_utf8_impl (cd_str_to_utf8, cd_chardet_to_utf8);
}