changeset 3209:41a91ed36bfa trunk

Use new combined libguess interface.
author William Pitcock <nenolod@atheme-project.org>
date Wed, 01 Aug 2007 08:12:03 -0500
parents 427f705be3bf
children 5939941ba48b
files src/audacious/strings.c
diffstat 1 files changed, 4 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/strings.c	Wed Aug 01 08:09:43 2007 -0500
+++ b/src/audacious/strings.c	Wed Aug 01 08:12:03 2007 -0500
@@ -36,7 +36,6 @@
 #include "main.h"
 
 #include "../libguess/libguess.h"
-#include "../librcd/librcd.h"
 #ifdef HAVE_UDET
     #include <libudet_c.h>
 #endif
@@ -286,48 +285,11 @@
 	if(cfg.chardet_detector)
 		det = cfg.chardet_detector;
 
+	guess_init();
+
 	if(det){
-		if(!strncasecmp("japanese", det, sizeof("japanese"))) {
-			encoding = (char *)guess_jp(str, strlen(str));
-			if (!encoding)
-				goto fallback;
-		} else if(!strncasecmp("taiwanese", det, sizeof("taiwanese"))) {
-			encoding = (char *)guess_tw(str, strlen(str));
-			if (!encoding)
-				goto fallback;
-		} else if(!strncasecmp("chinese", det, sizeof("chinese"))) {
-			encoding = (char *)guess_cn(str, strlen(str));
-			if (!encoding)
-				goto fallback;
-		} else if(!strncasecmp("korean", det, sizeof("korean"))) {
-			encoding = (char *)guess_kr(str, strlen(str));
-			if (!encoding)
-				goto fallback;
-		} else if(!strncasecmp("russian", det, sizeof("russian"))) {
-			rcd_russian_charset res = rcdGetRussianCharset(str, strlen(str));
-			switch(res) {
-			    case RUSSIAN_CHARSET_WIN:
-				encoding = "CP1251";
-			    break;
-			    case RUSSIAN_CHARSET_ALT:
-				encoding = "CP866";
-			    break;
-			    case RUSSIAN_CHARSET_KOI:
-				encoding = "KOI8-R";
-			    break;
-			    case RUSSIAN_CHARSET_UTF8:
-				encoding = "UTF-8";
-			    break;
-			}
-			if (!encoding)
-				goto fallback;
-#ifdef HAVE_UDET
-		} else if (!strncasecmp("universal", det, sizeof("universal"))) {
-			encoding = (char *)detectCharset((char *)str, strlen(str));
-			if (!encoding)
-				goto fallback;
-#endif
-		} else /* none, invalid */
+		encoding = (char *) guess_encoding(str, strlen(str), det);
+		if (!encoding)
 			goto fallback;
 
 		ret = g_convert(str, len, "UTF-8", encoding, bytes_read, bytes_write, error);