summaryrefslogtreecommitdiff
path: root/cdumb.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-24 21:19:29 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-24 21:19:29 +0100
commit5ee5ea4f0a6027e0261e4ee769bedb0e598c41de (patch)
tree675298a99462f802c04db15fc32527b8d74b52cd /cdumb.c
parentaa4832661a52fbcdccafae62fccb9e4901777f3d (diff)
iconv fixes for bsd compatibility
Diffstat (limited to 'cdumb.c')
-rw-r--r--cdumb.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cdumb.c b/cdumb.c
index f2a522e8..2eee3695 100644
--- a/cdumb.c
+++ b/cdumb.c
@@ -18,11 +18,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#define LIBICONV_PLUG
#include <iconv.h>
#include "dumb/dumb-kode54/include/dumb.h"
#include "dumb/dumb-kode54/include/internal/it.h"
#include "deadbeef.h"
+//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
+#define trace(fmt,...)
+
static DB_decoder_t plugin;
static DB_functions_t *deadbeef;
@@ -707,7 +711,11 @@ static const char *convstr (const char* str, int sz) {
// check for utf8 (hack)
iconv_t cd;
- cd = iconv_open ("utf8", "utf8");
+ cd = iconv_open ("utf-8", "utf-8");
+ if (cd == (iconv_t)-1) {
+ trace ("iconv doesn't support utf8\n");
+ return str;
+ }
size_t inbytesleft = sz;
size_t outbytesleft = 2047;
#ifdef __linux__
@@ -743,10 +751,10 @@ static const char *convstr (const char* str, int sz) {
enc = "cp1251";
}
#endif
- cd = iconv_open ("utf8", enc);
- if (!cd) {
- // printf ("unknown encoding: %s\n", enc);
- return NULL;
+ cd = iconv_open ("utf-8", enc);
+ if (cd == (iconv_t)-1) {
+ trace ("iconv can't recode from %s to utf8\n", enc);
+ return str;
}
else {
size_t inbytesleft = sz;