add character set conversion

This commit is contained in:
hummypkg 2017-03-09 15:25:49 +00:00 committed by HummyPkg
parent 2ffb32bcb4
commit abe92a3135
4 changed files with 25 additions and 4 deletions

View File

@ -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

1
lint.h
View File

@ -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 *);

9
main.c
View File

@ -1,6 +1,6 @@
/*
* Humax EPG Tool
* by af123, 2011 - 2016
* by af123, 2011 - 2017
*/
#include <stdio.h>
@ -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] <command>...\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);
}

17
util.c
View File

@ -13,6 +13,7 @@
#include <time.h>
#include <strings.h>
#include <stdarg.h>
#include <xconv.h>
#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)