Norwegian characters in TVGuide (2 Viewers)

tronyg

New Member
February 8, 2007
1
0
Home Country
Norway Norway
I have the same problem on XP, but with an analog card. I understand the solution above is for Dvb-grabbers, so are there anyone out there with an idea on how to fix this on my htpc? I appreciate any help very much :)
 

caid

Portal Member
November 25, 2007
13
1
Home Country
Norway Norway
Ok i finally made a patch for this bug, maybe not the most elegant method (have only done some HelloWorld applications in c++ before this), but it works.

Before this patch the getString468A() method in TsWriter stripped away important decoding info, I.E.:

10 00 01 (ISO-8859-1)
was converted too
01 (ISO-8859-5)
which dont have the norwegian characters¨.

Her are my solution:
PHP:
void CDvbUtil::getString468A(BYTE *b, int maxLen,char *text)
{
	int i = 0;
	int num=0;
	unsigned char c;
	char em_ON = (char)0x86;
	char em_OFF = (char)0x87;

	bool threeByteEncoding = false;

  if (maxLen< 1) return;
  if (text==NULL) return;
  if (b==NULL) return;

  int len=maxLen;
	do
	{
		c = (char)b[i];
	/*	if(c=='Ü')
		{
			int a=0;
		}*/

///////////// OK HERE IT STARTS

		// If first byte is 0x10 use three byte encoding (0x10 0x00 0xXX)
		if ( i == 0 && (BYTE)c == 0x10 )
		{
			threeByteEncoding = true;
			text[num] = 0x10;
			text[num+1]=0;
			num++;
			goto cont;
		}
		if ( i == 1 && threeByteEncoding == true )
		{
			//NOTE: using 0x00 will mess up the string, so i use 0x10  as a dummy value instead
			//           this value will be ignored by the DvbTextConverter.Convert() method anyway
			text[num] = 0x10;
			text[num+1]=0;
			num++;
			goto cont;
		}
		if ( i == 2 && threeByteEncoding == true )
		{
                      // if this value is invalid, the DvbTextConverter.Convert() method will fall back to default charset
			text[num] = c;
			
			text[num+1]=0;
			num++;
			goto cont;
		}

///////// END

		if ( (((BYTE)c) >= 0x80) && (((BYTE)c) <= 0x9F))
		{
			goto cont;
		}
		// GEMX: 11.04.08: This strips off a probably encoding pointer byte !!!
		/*if (i==0 && ((BYTE)c) < 0x20)
		{
			goto cont;
		}*/
				
		if (c == em_ON)
		{
			//					
			goto cont;
		}
		if (c == em_OFF)
		{
			//					
			goto cont;
		}
				
		if ( ((BYTE)c) == 0x84)
		{
      if (num >=maxLen) return;
			text[num] = '\r';
			text[num+1]=0;
			num++;
			goto cont;
		}
				
		if (((BYTE)c) < 0x20)
		{
      //0x1-0x5 = choose character set...
      if ((BYTE)c < 0x1 || (BYTE)c>0x5)
      {
			  goto cont;
      }
		}
				
      
    if (num >=maxLen) return;
		text[num] = c;
		text[num+1]=0;
		num++;
cont:
		len -= 1;
		i += 1;
	}while (!(len <= 0));

}
 

gemx

Retired Team Member
  • Premium Supporter
  • October 31, 2006
    1,972
    539
    Home Country
    Germany Germany
    Thanks,
    looks quite good - it's in SVN now :)
     

    ronilse

    Retired Team Member
  • Premium Supporter
  • July 19, 2005
    4,422
    283
    Moss
    Home Country
    Norway Norway
    Hi,
    Nice & good timing(just got a new psu so able to fire up htpc again & test), nice work ;)

    Regards
    Roy
     

    Users who are viewing this thread

    Top Bottom