[mythtv] [PATCH] Patch for siparser to detect and decode EIT with ISO-8859 encoding

Einar Bjarni Halldórsson einarb at gmail.com
Wed Feb 1 00:19:58 UTC 2006


Sorry about the resend, but my last post was all messed up, so here it
is again. This patch makes siparser detect and decode EIT encoded with
ISO-8859 encoding as declared in ETSI EN 300 468

Index: libs/libmythtv/siparser.cpp
===================================================================
--- libs/libmythtv/siparser.cpp	(revision 8736)
+++ libs/libmythtv/siparser.cpp	(working copy)
@@ -957,7 +957,7 @@
     unsigned char buf[length];
     memcpy(buf, src, length);

-    if ((buf[0] < 0x10) || (buf[0] >= 0x20))
+    if ((buf[0] < 0x10) || (buf[0] >= 0x20) || (buf[0] == 0x10))
     {
         // Strip formatting characters
         for (uint p = 0; p < length; p++)
@@ -976,18 +976,30 @@
             QTextCodec *codec = QTextCodec::codecForName(coding);
             result = codec->toUnicode((const char*)buf + 1, length - 1);
         }
+	else if (buf[0] == 0x10)
+	{
+		// If the first byte of the text field has a value "0x10" then the
following two bytes carry a 16-bit value (uimsbf) N
+		// to indicate that the remaining data of the text field is coded
using the character code table specified by
+		// ISO Standard 8859, parts 1 to 9
+
+		uint code = 1;
+		swab(buf + 1, &code, 2);
+		QString coding = "ISO8859-" + QString::number(code);
+		QTextCodec *codec = QTextCodec::codecForName(coding);
+		result = codec->toUnicode((const char*)buf + 3, length - 3);
+	}
         else
         {
-            // Unknown/invalid encoding - assume local8Bit
+	    // Unknown/invalid encoding - assume local8Bit
             result = QString::fromLocal8Bit((const char*)buf + 1, length - 1);
         }
     }
     else
     {
-        // TODO: Handle multi-byte encodings
+	// TODO: Handle multi-byte encodings

-        VERBOSE(VB_SIPARSER, LOC + "Multi-byte coded text - not supported!");
-        result = "N/A";
+	 VERBOSE(VB_SIPARSER, LOC + "Multi-byte coded text - not supported!");
+    	 result = "N/A";
     }

     return result;


More information about the mythtv-dev mailing list