[vdr] Converting from UTF-8 to ISO-8859-1

Klaus Schmidinger Klaus.Schmidinger at cadsoft.de
Sun May 18 18:39:31 CEST 2008


On 05/18/08 18:27, Joachim Wilke wrote:
> Dear experts,
> 
> I am currently trying to convert a string to ISO-8859-1 using the
> following code fragment:
> 
>   cCharSetConv conv(NULL, "ISO-8859-1");
>   const char *s_converted = conv.Convert(string);
> 
> Running VDR with UTF-8, this conversion failes (i.e., s_converted == string).
> This is due to the fact, that cCharSetConv::SystemCharacterTable contains "NULL"
> instead of "UTF-8". This is because systemCharacterTable is never set:
> 
> void cCharSetConv::SetSystemCharacterTable(const char *CharacterTable)
> {
>   free(systemCharacterTable);
>   systemCharacterTable = NULL;
>   if (!strcasestr(CharacterTable, "UTF-8")) {
>      ..
>      systemCharacterTable = strdup(CharacterTable);
>      }
> }
> 
> Is there a reason for this?

systemCharacterTable is only set if it is a single byte character set,
which UTF-8 is not.

> The conversion works fine, if I use  "UTF-8" instead of "NULL":
>   cCharSetConv conv("UTF-8", "ISO-8859-1");

Good, so it works as designed ;-)

Klaus



More information about the vdr mailing list