Ticket #1025: iso8859.diff

File iso8859.diff, 1.7 KB (added by Stuart Auchterlonie, 18 years ago)

Patch from Einar Bjarni Halldórsson <einarb at gmail.com>

  • libs/libmythtv/siparser.cpp

     
    957957    unsigned char buf[length];
    958958    memcpy(buf, src, length);
    959959
    960     if ((buf[0] < 0x10) || (buf[0] >= 0x20))
     960    if ((buf[0] < 0x10) || (buf[0] >= 0x20) || (buf[0] == 0x10))
    961961    {
    962962        // Strip formatting characters
    963963        for (uint p = 0; p < length; p++)
     
    976976            QTextCodec *codec = QTextCodec::codecForName(coding);
    977977            result = codec->toUnicode((const char*)buf + 1, length - 1);
    978978        }
     979        else if (buf[0] == 0x10)
     980        {
     981                // If the first byte of the text field has a value "0x10" then the following two bytes carry a 16-bit value (uimsbf) N
     982                // to indicate that the remaining data of the text field is coded using the character code table specified by
     983                // ISO Standard 8859, parts 1 to 9
     984
     985                uint code = 1;
     986                swab(buf + 1, &code, 2);
     987                QString coding = "ISO8859-" + QString::number(code);
     988                QTextCodec *codec = QTextCodec::codecForName(coding);
     989                result = codec->toUnicode((const char*)buf + 3, length - 3);
     990        }
    979991        else
    980992        {
    981             // Unknown/invalid encoding - assume local8Bit
     993            // Unknown/invalid encoding - assume local8Bit
    982994            result = QString::fromLocal8Bit((const char*)buf + 1, length - 1);
    983995        }
    984996    }
    985997    else
    986998    {
    987         // TODO: Handle multi-byte encodings
     999        // TODO: Handle multi-byte encodings
    9881000
    989         VERBOSE(VB_SIPARSER, LOC + "Multi-byte coded text - not supported!");
    990         result = "N/A";
     1001        VERBOSE(VB_SIPARSER, LOC + "Multi-byte coded text - not supported!");
     1002        result = "N/A";
    9911003    }
    9921004
    9931005    return result;