summaryrefslogtreecommitdiff
path: root/charset.c
diff options
context:
space:
mode:
authorMatti Lehtimäki <matti.lehtimaki@gmail.com>2012-05-12 14:42:01 +0300
committerMatti Lehtimäki <matti.lehtimaki@gmail.com>2012-05-12 14:42:01 +0300
commit6b488dcedf24cf9b4890505eba992d683eedecac (patch)
tree51347d76c4b2891568e54348d9ce0ab99304bd0b /charset.c
parent548e0a6bc35d4c776039f7467c0d67eabf9ef46a (diff)
downloadvdr-plugin-epgfixer-6b488dcedf24cf9b4890505eba992d683eedecac.tar.gz
vdr-plugin-epgfixer-6b488dcedf24cf9b4890505eba992d683eedecac.tar.bz2
Support for ignoring and copying EPG data. Bug fixes.
Fix character set conversion for selected channels. Fix and improve Makefile (thanks to Ville Skyttä and Rolf Ahrenberg). Fix compiling with g++-4.7.
Diffstat (limited to 'charset.c')
-rw-r--r--charset.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/charset.c b/charset.c
index 84056bf..c502e90 100644
--- a/charset.c
+++ b/charset.c
@@ -6,39 +6,45 @@
*/
#include "charset.h"
-#include <unistd.h>
/* Global instance */
-cEpgfixerList<cCharSet> EpgfixerCharSets;
+cEpgfixerList<cCharSet, cEvent> EpgfixerCharSets;
cCharSet::cCharSet()
{
- charset = NULL;
+ origcharset = NULL;
+ realcharset = NULL;
}
cCharSet::~cCharSet(void)
{
- free(charset);
+ free(origcharset);
+ free(realcharset);
}
bool cCharSet::Apply(cEvent *Event)
{
if (enabled && IsActive(Event->ChannelID())) {
- cCharSetConv conv(charset, cCharSetConv::SystemCharacterTable());
- Event->SetTitle(conv.Convert(Event->Title()));
- Event->SetShortText(conv.Convert(Event->ShortText()));
- Event->SetDescription(conv.Convert(Event->Description()));
+ cCharSetConv backconv(cCharSetConv::SystemCharacterTable(), origcharset ? origcharset : "iso6937");
+ cString title(backconv.Convert(Event->Title()));
+ cString shortText(backconv.Convert(Event->ShortText()));
+ cString description(backconv.Convert(Event->Description()));
+ cCharSetConv conv(realcharset, cCharSetConv::SystemCharacterTable());
+ Event->SetTitle(conv.Convert(title));
+ Event->SetShortText(conv.Convert(shortText));
+ Event->SetDescription(conv.Convert(description));
}
return false;
}
void cCharSet::SetFromString(char *s, bool Enabled)
{
- FREE(charset);
+ FREE(origcharset);
+ FREE(realcharset);
Free();
enabled = Enabled;
if (s[0] == '!')
- string = strdup(s+1);
+ string = strdup(s + 1);
else
string = strdup(s);
if (s[0] == '!' || s[0] == '#')
@@ -46,19 +52,19 @@ void cCharSet::SetFromString(char *s, bool Enabled)
char *p = (s[0] == '#') ? NULL : s;
if (p) {
char *p = (s[0] == '!') ? s+1 : s;
- char *f = strchr(p, ':');
- if (f) {
- *f = 0;
- charset = strdup(f + 1);
+ char *r = strchr(p, ':');
+ if (r) {
+ *r = 0;
numchannels = LoadChannelsFromString(p);
+ p = r + 1;
+ }
+ r = strchr(p, '=');
+ if (r) {
+ *r = 0;
+ origcharset = strdup(p);
+ realcharset = strdup(r + 1);
}
else
- charset = strdup(p);
+ realcharset = strdup(p);
}
}
-
-void cCharSet::PrintConfigLineToFile(FILE *f)
-{
- if (f)
- fprintf(f, "%s%s\n", enabled ? "" : "!", string);
-}