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

Klaus Schmidinger Klaus.Schmidinger at cadsoft.de
Sun May 18 22:49:27 CEST 2008

On 05/18/08 18:53, Joachim Wilke wrote:
> 2008/5/18 Klaus Schmidinger <Klaus.Schmidinger at cadsoft.de>:
>> On 05/18/08 18:27, Joachim Wilke wrote:
>>> 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 ;-)
> Hi Klaus,
> so what do I have to do, to convert a string (from whatever encoding
> VDR currently uses) to ISO-8859-1 ?
> Do I really have to do:
>   if(cCharSetConv::SystemCharacterTable == NULL)
>     cCharSetConv conv("UTF-8", "ISO-8859-1");
>   else
>     cCharSetConv conv(NULL, "ISO-8859-1");
>   const char *s_converted = conv.Convert(string);
> This is against the generic use of "NULL" as parameter, in my opinion.

Actually this conversion wasn't necessary so far.
It was always about converting strings from "some external character set"
to "the character set used by the system".

But I guess it should be ok to do this (modified lines marked with MOD):

cCharSetConv::cCharSetConv(const char *FromCode, const char *ToCode)
   if (!FromCode)
      FromCode = systemCharacterTable ? systemCharacterTable : "UTF-8"; //MOD
   if (!ToCode)
      ToCode = "UTF-8";
   cd = iconv_open(ToCode, FromCode); //MOD
   result = NULL;
   length = 0;
const char *cCharSetConv::Convert(const char *From, char *To, size_t ToLength)
   if (From && *From) { //MOD

Please try this and let me know if it works and doesn't break anything else.


More information about the vdr mailing list