From abe92a3135c73faca79b5771363d5a02028e72cd Mon Sep 17 00:00:00 2001 From: hummypkg Date: Thu, 9 Mar 2017 15:25:49 +0000 Subject: [PATCH] add character set conversion --- Makefile | 2 +- lint.h | 1 + main.c | 9 ++++++--- util.c | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5626df3..db72e45 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ WARN=-pedantic -Wall -W -Wnested-externs -Wpointer-arith -Wno-long-long PLATFORM=$(shell uname -s | cut -d- -f1) ifeq ($(PLATFORM),Linux) DEFS=-DHAVE_SQLITE3 -LIBS=-lsqlite3 +LIBS=-lsqlite3 -lxconv endif all: tags epg diff --git a/lint.h b/lint.h index 6670943..ff290cb 100644 --- a/lint.h +++ b/lint.h @@ -23,6 +23,7 @@ char *ctime_nl(time_t *); time_t mjd(uint16_t, int, int, int); void safeprintf(char *, ...); void uncompress_epg(char **, unsigned int *); +void iso6937_convert(char **, unsigned int *); struct epg *open_file(char *); void close_file(struct epg *); diff --git a/main.c b/main.c index 7479cf9..4882cc4 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,6 @@ /* * Humax EPG Tool - * by af123, 2011 - 2016 + * by af123, 2011 - 2017 */ #include @@ -21,7 +21,7 @@ #include "lint.h" int debug = 0; -const char *version = "1.2.4"; +const char *version = "1.2.6"; unsigned long sysopts = 0; unsigned long filterflags = 0; static time_t latest_stamp = 0; @@ -34,7 +34,7 @@ sqlite3_stmt *stmt; int syntax() { - fprintf(stderr, "Humax EPG Tool v%s, by af123, 2011-2016.\n\n", + fprintf(stderr, "Humax EPG Tool v%s, by af123, 2011-2017.\n\n", version); fprintf(stderr, "Syntax: epg [options] [filters] ...\n\n"); @@ -320,6 +320,9 @@ sqlitedump(struct epg *epg __attribute__((unused)), DECOMPRESS(d->content.d77.name, d->content.d77.namelen); DECOMPRESS(d->content.d77.text, d->content.d77.textlen); + iso6937_convert(&d->content.d77.name, &d->content.d77.namelen); + iso6937_convert(&d->content.d77.text, &d->content.d77.textlen); + sqlite3_bind_text(stmt, 6, d->content.d77.name, -1, NULL); sqlite3_bind_text(stmt, 7, d->content.d77.text, -1, NULL); } diff --git a/util.c b/util.c index 3511247..09aae3c 100644 --- a/util.c +++ b/util.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "lint.h" @@ -32,6 +33,22 @@ uncompress_epg(char **epg, unsigned int *epglen) } } +void +iso6937_convert(char **str, unsigned int *len) +{ + char dst[0x200]; + int newlen; + + newlen = xconv(*str, dst, sizeof(dst)); + + if (newlen) + { + free(*str); + *str = strdup(dst); + *len = newlen; + } +} + #ifdef sun char * strcasestr (char *h, char *n)