Re: bad characters in epg.data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 02 2015, Klaus Schmidinger wrote:

>> C S19.2E-133-3-263 SVM - GR\326D
>> 
>> Would it be possible/easy to patch vdr to filter out such errors?
>> What is the right function to look at?
>
> Take a look at StripControlCharacters() or cEvent::FixEpgBugs() in epg.c.

It seems, that these functions only take care of the title and the
description, but not the channel name.

Finally, I've patched vdr like this:

--8<---------------cut here---------------start------------->8---
--- epg.c~      2013-12-28 12:33:08.000000000 +0100
+++ epg.c       2015-12-06 15:54:58.312233837 +0100
@@ -1064,11 +1064,32 @@
         }
 }
 
+static char *StripFunny8bitCharacters(const char *src)
+{
+    static char dest[100];
+    strn0cpy(dest, src, 100);
+    char *s = dest;
+    int len = strlen(s);
+    while (len > 0) {
+        int l = Utf8CharLen(s);
+        uchar *p = (uchar *)s;
+        if (l == 1 && *p > 0x7F) {  // this is not utf-8
+            memmove(s, p + 1, len); // we also copy the terminating 0!
+            len--;
+            l = 0;
+        }
+        s += l;
+        len -= l;
+    }
+    return dest;
+}
+
 void cSchedule::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime) const
 {
   cChannel *channel = Channels.GetByChannelID(channelID, true);
   if (channel) {
-     fprintf(f, "%sC %s %s\n", Prefix, *channel->GetChannelID().ToString(), channel->Name());
+     fprintf(f, "%sC %s %s\n", Prefix, *channel->GetChannelID().ToString(),
+             StripFunny8bitCharacters(channel->Name()));
      const cEvent *p;
      switch (DumpMode) {
        case dmAll: {
--8<---------------cut here---------------end--------------->8---

It seems to work.
Would it be possible to integrate this patch into vdr?

-- 
           Peter


_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr




[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux