[scrapers] Fix processing xml files with incorrect suggested encoding or incorrect encoding in xml declaration
CLog::Log(LOGDEBUG,"scraper: %s returned %s",function.c_str(),strXML.c_str());
CXBMCTinyXML doc;
- doc.Parse(strXML, TIXML_ENCODING_UNKNOWN);
+ /* all data was converted to UTF-8 before being processed by scraper */
+ doc.Parse(strXML, TIXML_ENCODING_UTF8);
if (!doc.RootElement())
{
CLog::Log(LOGERROR, "%s: Unable to parse XML",__FUNCTION__);
return false;
CXBMCTinyXML doc;
- doc.Parse(strUrl, TIXML_ENCODING_UNKNOWN);
+ /* strUrl is coming from internal sources (usually generated by scraper or from database)
+ * so strUrl is always in UTF-8 */
+ doc.Parse(strUrl, TIXML_ENCODING_UTF8);
TiXmlElement* pElement = doc.RootElement();
if (!pElement)
// ok, now parse the xml file
CXBMCTinyXML doc;
- doc.Parse(strUrls, TIXML_ENCODING_UNKNOWN);
+ /* strUrls is coming from internal sources so strUrls is always in UTF-8 */
+ doc.Parse(strUrls, TIXML_ENCODING_UTF8);
if (doc.RootElement())
{
TiXmlHandle docHandle( &doc );
else if (!tryDataCharset.empty())
{
std::string converted;
- if (!g_charsetConverter.ToUtf8(tryDataCharset, data, converted) || converted.empty())
+ /* some wrong conversions can leave US-ASCII XML header and structure untouched but break non-English data
+ * so conversion must fail on wrong character and then other encodings will be tried */
+ if (!g_charsetConverter.ToUtf8(tryDataCharset, data, converted, true) || converted.empty())
return false; // can't convert data
InternalParse(converted, TIXML_ENCODING_UTF8);