1 #include <lib/base/encoding.h>
2 #include <lib/base/eerror.h>
4 eDVBTextEncodingHandler encodingHandler; // the one and only instance
6 inline char toupper(char c)
16 eDVBTextEncodingHandler::eDVBTextEncodingHandler()
18 const char * file=DATADIR "/enigma2/encoding.conf";
19 FILE *f = fopen(file, "rt");
22 char *line = (char*) malloc(256);
24 char countrycode[256];
25 while( getline(&line, &bufsize, f) != -1 )
29 int tsid, onid, encoding;
30 if ( sscanf( line, "%s ISO8859-%d", countrycode, &encoding ) == 2 )
32 m_CountryCodeDefaultMapping[countrycode]=encoding;
33 countrycode[0]=toupper(countrycode[0]);
34 countrycode[1]=toupper(countrycode[1]);
35 countrycode[2]=toupper(countrycode[2]);
36 m_CountryCodeDefaultMapping[countrycode]=encoding;
38 else if ( (sscanf( line, "0x%x 0x%x ISO8859-%d", &tsid, &onid, &encoding ) == 3 )
39 ||(sscanf( line, "%d %d ISO8859-%d", &tsid, &onid, &encoding ) == 3 ) )
40 m_TransponderDefaultMapping[(tsid<<16)|onid]=encoding;
41 else if ( (sscanf( line, "0x%x 0x%x", &tsid, &onid ) == 2 )
42 ||(sscanf( line, "%d %d", &tsid, &onid ) == 2 ) )
43 m_TransponderUseTwoCharMapping.insert((tsid<<16)|onid);
45 eDebug("couldn't parse %s", line);
51 eDebug("[eDVBTextEncodingHandler] couldn't open %s !", file);
54 void eDVBTextEncodingHandler::getTransponderDefaultMapping(int tsidonid, int &table)
56 std::map<int, int>::iterator it =
57 m_TransponderDefaultMapping.find(tsidonid);
58 if ( it != m_TransponderDefaultMapping.end() )
62 bool eDVBTextEncodingHandler::getTransponderUseTwoCharMapping(int tsidonid)
64 return m_TransponderUseTwoCharMapping.find(tsidonid) != m_TransponderUseTwoCharMapping.end();
67 int eDVBTextEncodingHandler::getCountryCodeDefaultMapping( const std::string &country_code )
69 std::map<std::string, int>::iterator it =
70 m_CountryCodeDefaultMapping.find(country_code);
71 if ( it != m_CountryCodeDefaultMapping.end() )
73 return 0; // ISO8859-1 / Latin1