1 #include <lib/base/encoding.h>
2 #include <lib/base/eerror.h>
5 eDVBTextEncodingHandler encodingHandler; // the one and only instance
17 eDVBTextEncodingHandler::eDVBTextEncodingHandler()
19 const char * file=DATADIR "/enigma2/encoding.conf";
20 FILE *f = fopen(file, "rt");
23 char *line = (char*) malloc(256);
25 char countrycode[256];
26 while( getline(&line, &bufsize, f) != -1 )
30 int tsid, onid, encoding;
31 if ( sscanf( line, "%s ISO8859-%d", countrycode, &encoding ) == 2 )
33 m_CountryCodeDefaultMapping[countrycode]=encoding;
34 countrycode[0]=toupper(countrycode[0]);
35 countrycode[1]=toupper(countrycode[1]);
36 countrycode[2]=toupper(countrycode[2]);
37 m_CountryCodeDefaultMapping[countrycode]=encoding;
39 else if ( (sscanf( line, "0x%x 0x%x ISO8859-%d", &tsid, &onid, &encoding ) == 3 )
40 ||(sscanf( line, "%d %d ISO8859-%d", &tsid, &onid, &encoding ) == 3 ) )
41 m_TransponderDefaultMapping[(tsid<<16)|onid]=encoding;
42 else if ( (sscanf( line, "0x%x 0x%x", &tsid, &onid ) == 2 )
43 ||(sscanf( line, "%d %d", &tsid, &onid ) == 2 ) )
44 m_TransponderUseTwoCharMapping.insert((tsid<<16)|onid);
46 eDebug("couldn't parse %s", line);
52 eDebug("[eDVBTextEncodingHandler] couldn't open %s !", file);
55 void eDVBTextEncodingHandler::getTransponderDefaultMapping(int tsidonid, int &table)
57 std::map<int, int>::iterator it =
58 m_TransponderDefaultMapping.find(tsidonid);
59 if ( it != m_TransponderDefaultMapping.end() )
63 bool eDVBTextEncodingHandler::getTransponderUseTwoCharMapping(int tsidonid)
65 return m_TransponderUseTwoCharMapping.find(tsidonid) != m_TransponderUseTwoCharMapping.end();
68 int eDVBTextEncodingHandler::getCountryCodeDefaultMapping( const std::string &country_code )
70 std::map<std::string, int>::iterator it =
71 m_CountryCodeDefaultMapping.find(country_code);
72 if ( it != m_CountryCodeDefaultMapping.end() )
74 return 0; // ISO8859-1 / Latin1