#! /bin/sh /usr/share/dpatch/dpatch-run ## 17_epg-conv-iso6937.dpatch by Thomas Günther ## http://toms-cafe.de/vdr/download/vdr-epg-conv-iso6937-1.4.5.diff ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Convert EPG of UPC Direct / HBO from iso6937 to iso8859-2. @DPATCH@ --- vdr-1.4.5/epg.c +++ vdr-1.4.5/epg.c @@ -15,6 +15,28 @@ #include #include "libsi/si.h" #include "timers.h" +#include +static void ConvertFromISO6937(char *text) +{ + // Convert text from iso6937 to iso8859-2 (only if text contains one of 0xC1..0xC8, 0xCA, 0xCB, 0xCD..0xCF) + if (!text || strcspn(text, "\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xCA\xCB\xCD\xCE\xCF") == strlen(text)) return; + char *buffer = strdup(text); + iconv_t ic = iconv_open("iso8859-2", "iso6937"); + if (ic >= 0) { + char *in = text; + char *out = buffer; + size_t inbytesleft = strlen(text); + size_t outbytesleft = inbytesleft; + if (iconv(ic, &in, &inbytesleft, &out, &outbytesleft) != (size_t)(-1)) { + *out = 0; + strcpy(text, buffer); + } + else + dsyslog("Converting from iso6937 failed at: %s", in); + iconv_close(ic); + } + free(buffer); +} #define RUNNINGSTATUSTIMEOUT 30 // seconds before the running status is considered unknown @@ -641,6 +663,11 @@ strreplace(shortText, '\x87', ' '); strreplace(description, '\x86', ' '); strreplace(description, '\x87', ' '); + + // Check for iso6937 characters in EPG and convert them if possible + ConvertFromISO6937(title); + ConvertFromISO6937(shortText); + ConvertFromISO6937(description); } // --- cSchedule -------------------------------------------------------------