]> git.sesse.net Git - vlc/commitdiff
DVB: strip character emphasis control codes
authorRafaël Carré <funman@videolan.org>
Tue, 9 Sep 2014 10:05:07 +0000 (12:05 +0200)
committerRafaël Carré <funman@videolan.org>
Tue, 9 Sep 2014 10:13:47 +0000 (12:13 +0200)
Fix display of BSkyB program names as 0x86Foobar0x87

modules/demux/dvb-text.h

index 6f15554940691ef349b25bda6f5a5d6f587953ad..2aae51f9c451b8db7edbc032a6fe08f9478898ac 100644 (file)
@@ -94,6 +94,7 @@ static char *vlc_from_EIT (const void *buf, size_t length)
         EnsureUTF8 (out);
     }
 
+    length = strlen(out);
     /* Convert control codes */
     for (char *p = strchr (out, '\xC2'); p; p = strchr (p + 1, '\xC2'))
     {
@@ -104,6 +105,16 @@ static char *vlc_from_EIT (const void *buf, size_t length)
          * 0x8B-0x9F are unspecified. */
         if (p[1] == '\x8A')
             memcpy (p, "\r\n", 2);
+
+        /* Strip character emphasis */
+        if (p[1] == '\x86' || p[1] == '\x87') {
+            const size_t n = p - out;
+            memmove (p, p+2, length - n);
+            length -= 2;
+            out[length] = '\0';
+            if (length == n)
+                break;
+        }
     }
 
     /* Private use area */
@@ -114,6 +125,16 @@ static char *vlc_from_EIT (const void *buf, size_t length)
             continue;
         if (p[2] == '\x8A')
             memcpy (p, "\r\r\n", 3); /* we need three bytes, so to CRs ;) */
+
+        /* Strip character emphasis */
+        if (p[2] == '\x86' || p[2] == '\x87') {
+            const size_t n = p - out;
+            memmove (p, p+3, length - n);
+            length -= 3;
+            out[length] = '\0';
+            if (length == n)
+                break;
+        }
     }
 
     return out;