1 #include <lib/base/encoding.h>
2 #include <lib/base/eerror.h>
5 eDVBTextEncodingHandler encodingHandler; // the one and only instance
7 eDVBTextEncodingHandler::eDVBTextEncodingHandler()
9 const char * file=DATADIR "/enigma2/encoding.conf";
10 FILE *f = fopen(file, "rt");
13 char *line = (char*) malloc(256);
15 char countrycode[256];
16 while( getline(&line, &bufsize, f) != -1 )
20 int tsid, onid, encoding;
21 if ( sscanf( line, "%s ISO8859-%d", countrycode, &encoding ) == 2 )
22 m_CountryCodeDefaultMapping[countrycode]=encoding;
23 else if ( (sscanf( line, "0x%x 0x%x ISO8859-%d", &tsid, &onid, &encoding ) == 3 )
24 ||(sscanf( line, "%d %d ISO8859-%d", &tsid, &onid, &encoding ) == 3 ) )
25 m_TransponderDefaultMapping[(tsid<<16)|onid]=encoding;
26 else if ( (sscanf( line, "0x%x 0x%x", &tsid, &onid ) == 2 )
27 ||(sscanf( line, "%d %d", &tsid, &onid ) == 2 ) )
28 m_TransponderUseTwoCharMapping.insert((tsid<<16)|onid);
30 eDebug("couldn't parse %s", line);
36 eDebug("[eDVBTextEncodingHandler] couldn't open %s !", file);
39 void eDVBTextEncodingHandler::getTransponderDefaultMapping(int tsidonid, int &table)
41 std::map<int, int>::iterator it =
42 m_TransponderDefaultMapping.find(tsidonid);
43 if ( it != m_TransponderDefaultMapping.end() )
47 bool eDVBTextEncodingHandler::getTransponderUseTwoCharMapping(int tsidonid)
49 return m_TransponderUseTwoCharMapping.find(tsidonid) != m_TransponderUseTwoCharMapping.end();
52 int eDVBTextEncodingHandler::getCountryCodeDefaultMapping( const std::string &country_code )
54 std::map<std::string, int>::iterator it =
55 m_CountryCodeDefaultMapping.find(country_code);
56 if ( it != m_CountryCodeDefaultMapping.end() )
58 return 0; // ISO8859-1 / Latin1