RSS to support Chinese text code?
#1
i try to use chinese news web rss feed, but seen the xbmc's rss reader can not decode the chinese or unicode, result just some character.

so, now the rss feed are not support the unicode or double-byte language?
Reply
#2
when rss is chinese ,it'll halt.

19-07-2005 fixed: utf16 rss feeds should at least display

but can rss support utf8 chinese code?
Reply
#3
an example of such a stream is needed.

if it has the encoding correctly specified, then it should work ok.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#4
first,thank you for your replying!
if you have time,maybe you can try the hyperlink
http://rss.sina.com.cn/news/marquee/ddt.xml
and find why the rss feed is broke.
Reply
#5
the feed shows in xbmc.

no idea if it works or not, as i'm not chinese, and nor do i have a chinese font installed.

perhaps you could state:

1. a font to use.
2. the charset i should use in xbmc
3. what the thing should look like (screenshot from a windows rss reader maybe?)

cheers,
jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#6
above all,i use the gbk  character set,and chose the language chinese(simple).

then ,i try the default font to show the rss feed,and it can be see and roll in the right place ,the same to songti.ttf (get from the xpv fonts directory).
while if use simyou.ttf(get from the office(chinese simple)),the system become very slow and can see everything but rss.

but all these changes can not show the correct strings ,it can only display the unicode string .

as you know,chinese use double byte while english use single byte,so,it need to combine the two code into one that can display chinese correctly.

since xbmc can support chinese outlook,i belive that it'll not too difficult to modify the source code to make rss support chinese.

looking forward to your help.

best regard,
hibaby
Reply
#7
i just fixed the rss code now and it should support chinese correctly if you have the right ttf in place. please check it out and let me know if it works for you.

-yuval
Reply
#8
thank you,and i'll try to compile the source code and try it tonight.

btw:
i rewrite the guitextbox.cpp.and make it support doublebyte language,the code is shown in the following:

new:
void cguitextbox:Confusedettext(const wstring &strtext)
{
m_vecitems.erase(m_vecitems.begin(), m_vecitems.end());
// start wordwrapping
// set a flag so we can determine initial justification effects
bool bstartingnewline = true;
bool bbreakatspace = false;
int pos = 0;
int itextsize = (int)strtext.size();
int lpos = 0;
char szline[1024];
int itotallines = 0;
int idoublebyte = 0;////////////// add
while (pos < itextsize)
{
// get the current letter in the string
char letter = (char)strtext[pos];

// break if we get more pages then maxpages
if (((itotallines + 1) / m_iitemsperpage) > (m_imaxpages - 1)) break;

// handle the newline character
if (letter == '\n' )
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
lpos = 0;
szline[0] = 0; // reset in case of 2 line breaks in a row (don't want to add szline twice)
}
else
{
if ((lpos < 0) || (lpos > 1023 && letter<0x80) || (lpos > 1022 && letter>0x7f))
{
outputdebugstring("cguitextbox:Confusedettext -> errror\n");
}
szline[lpos] = letter;
if ((letter>0x7f) &&( pos < itextsize-1 ))
{
idoublebyte=1;
szline[lpos + 1] = (char)strtext[pos+1];
szline[lpos + 2] = 0;
}
else
{
idoublebyte=0;
szline[lpos + 1] = 0;
}

float fwidth, fheight;
cstdstringw strtextunicode;
g_charsetconverter.stringcharsettofontcharset(szline, strtextunicode);

if (m_pfont)
m_pfont->gettextextent( strtextunicode.c_str(), &fwidth, &fheight);

if (fwidth > m_dwwidth)
{
idoublebyte=-1;
szline[lpos]=0;
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
lpos = 0;
}
else
{
lpos = lpos +idoublebyte+1;
}
}
pos = pos +idoublebyte+1;
}

if (lpos > 0)
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
}

int ipages = m_vecitems.size() / m_iitemsperpage;
if (m_vecitems.size() % m_iitemsperpage) ipages++;
m_updown.setrange(1, ipages);
m_updown.setvalue(1);

}


old:
void cguitextbox:Confusedettext(const wstring &strtext)
{
m_vecitems.erase(m_vecitems.begin(), m_vecitems.end());
// start wordwrapping
// set a flag so we can determine initial justification effects
bool bstartingnewline = true;
bool bbreakatspace = false;
int pos = 0;
int itextsize = (int)strtext.size();
int lpos = 0;
int ilastspace = -1;
int ilastspaceinline = -1;
char szline[1024];
wchar wstmp[1024];
int itotallines = 0;
while (pos < itextsize)
{
// get the current letter in the string
char letter = (char)strtext[pos];

// break if we get more pages then maxpages
if (((itotallines + 1) / m_iitemsperpage) > (m_imaxpages - 1)) break;

// handle the newline character
if (letter == '\n' )
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
ilastspace = -1;
ilastspaceinline = -1;
lpos = 0;
szline[0] = 0; // reset in case of 2 line breaks in a row (don't want to add szline twice)
}
else
{
if (letter == ' ')
{
ilastspace = pos;
ilastspaceinline = lpos;
}

if (lpos < 0 || lpos > 1023)
{
outputdebugstring("cguitextbox:Confusedettext -> errror\n");
}
szline[lpos] = letter;
szline[lpos + 1] = 0;

float fwidth, fheight;
swprintf(wstmp, l"%s", szline);
if (m_pfont)
m_pfont->gettextextent(wstmp, &fwidth, &fheight);
if (fwidth > m_dwwidth)
{
if (ilastspace > 0 && ilastspaceinline != lpos)
{
szline[ilastspaceinline] = 0;
pos = ilastspace;
}
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
ilastspaceinline = -1;
ilastspace = -1;
lpos = 0;
}
else
{
lpos++;
}
}
pos++;
}

if (lpos > 0)
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
}

int ipages = m_vecitems.size() / m_iitemsperpage;
if (m_vecitems.size() % m_iitemsperpage) ipages++;
m_updown.setrange(1, ipages);
m_updown.setvalue(1);

}
Reply
#9
Thumbs Up 
(hibaby @ july 26 2005,08:29 Wrote:i rewrite the guitextbox.cpp.and make it support doublebyte language,the code is shown in the following:

new:
void cguitextbox:Confusedettext(const wstring &strtext)
{
 m_vecitems.erase(m_vecitems.begin(), m_vecitems.end());
 // start wordwrapping
 // set a flag so we can determine initial justification effects
 bool bstartingnewline = true;
 bool bbreakatspace = false;
 int pos = 0;
 int itextsize = (int)strtext.size();
 int lpos = 0;
 char szline[1024];
 int itotallines = 0;
 int idoublebyte = 0;////////////// add
 while (pos < itextsize)
 {
   // get the current letter in the string
   char letter = (char)strtext[pos];

   // break if we get more pages then maxpages
   if (((itotallines + 1) / m_iitemsperpage) > (m_imaxpages - 1)) break;

   // handle the newline character
   if (letter == '\n' )
   {
     cguilistitem item(szline);
     m_vecitems.push_back(item);
     itotallines++;
     lpos = 0;
     szline[0] = 0;  // reset in case of 2 line breaks in a row (don't want to add szline twice)
   }
   else
   {
     if ((lpos < 0) || (lpos > 1023 && letter<0x80) ||  (lpos > 1022 && letter>0x7f))
     {
       outputdebugstring("cguitextbox:Confusedettext -> errror\n");
     }
 szline[lpos] = letter;
 if ((letter>0x7f) &&( pos < itextsize-1 ))
 {
       idoublebyte=1;
   szline[lpos + 1] =  (char)strtext[pos+1];
   szline[lpos + 2] = 0;
 }
 else
 {
       idoublebyte=0;
   szline[lpos + 1] = 0;
 }

 float fwidth, fheight;
     cstdstringw strtextunicode;
     g_charsetconverter.stringcharsettofontcharset(szline, strtextunicode);

 if (m_pfont)
       m_pfont->gettextextent( strtextunicode.c_str(), &fwidth, &fheight);

 if (fwidth > m_dwwidth)
     {
       idoublebyte=-1;
szline[lpos]=0;
cguilistitem item(szline);
       m_vecitems.push_back(item);
       itotallines++;
       lpos = 0;
     }
     else
     {
       lpos = lpos +idoublebyte+1;
     }
   }
   pos =  pos +idoublebyte+1;
 }

 if (lpos > 0)
 {
   cguilistitem item(szline);
   m_vecitems.push_back(item);
   itotallines++;
 }

 int ipages = m_vecitems.size() / m_iitemsperpage;
 if (m_vecitems.size() % m_iitemsperpage) ipages++;
 m_updown.setrange(1, ipages);
 m_updown.setvalue(1);

}


old:
void cguitextbox:Confusedettext(const wstring &strtext)
{
 m_vecitems.erase(m_vecitems.begin(), m_vecitems.end());
 // start wordwrapping
 // set a flag so we can determine initial justification effects
 bool bstartingnewline = true;
 bool bbreakatspace = false;
 int pos = 0;
 int itextsize = (int)strtext.size();
 int lpos = 0;
 int ilastspace = -1;
 int ilastspaceinline = -1;
 char szline[1024];
 wchar wstmp[1024];
 int itotallines = 0;
 while (pos < itextsize)
 {
   // get the current letter in the string
   char letter = (char)strtext[pos];

   // break if we get more pages then maxpages
   if (((itotallines + 1) / m_iitemsperpage) > (m_imaxpages - 1)) break;

   // handle the newline character
   if (letter == '\n' )
   {
     cguilistitem item(szline);
     m_vecitems.push_back(item);
     itotallines++;
     ilastspace = -1;
     ilastspaceinline = -1;
     lpos = 0;
     szline[0] = 0;  // reset in case of 2 line breaks in a row (don't want to add szline twice)
   }
   else
   {
     if (letter == ' ')
     {
       ilastspace = pos;
       ilastspaceinline = lpos;
     }

     if (lpos < 0 || lpos > 1023)
     {
       outputdebugstring("cguitextbox:Confusedettext -> errror\n");
     }
     szline[lpos] = letter;
     szline[lpos + 1] = 0;

     float fwidth, fheight;
     swprintf(wstmp, l"%s", szline);
     if (m_pfont)
       m_pfont->gettextextent(wstmp, &fwidth, &fheight);
     if (fwidth > m_dwwidth)
     {
       if (ilastspace > 0 && ilastspaceinline != lpos)
       {
         szline[ilastspaceinline] = 0;
         pos = ilastspace;
       }
       cguilistitem item(szline);
       m_vecitems.push_back(item);
       itotallines++;
       ilastspaceinline = -1;
       ilastspace = -1;
       lpos = 0;
     }
     else
     {
       lpos++;
     }
   }
   pos++;
 }

 if (lpos > 0)
 {
   cguilistitem item(szline);
   m_vecitems.push_back(item);
   itotallines++;
 }

 int ipages = m_vecitems.size() / m_iitemsperpage;
 if (m_vecitems.size() % m_iitemsperpage) ipages++;
 m_updown.setrange(1, ipages);
 m_updown.setvalue(1);

}
nice, please remember to submit it as a patch (link)
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#10
Quote:nice, please remember to submit it as a patch (link)

but i haven't try it :d ,if it works well i will post it.
Reply
#11
(yuvalt @ july 25 2005,22:43 Wrote:i just fixed the rss code now and it should support chinese correctly if you have the right ttf in place. please check it out and let me know if it works for you.

-yuval
it still doesn't work,please modify it again.

regards,

hibaby
Reply
#12
i tried the above rss with arialuni.ttf and this is what i got:

Image

it looks good to me (i compared the signed with the xml as displayed in ie).

what is the problem?

thanks,

-yuval



Reply
#13
i just fixed it so it will. if it still doesn't work for you, send me the rss url and the ttf file that you used.

-yuval
Reply
#14
it's cool!

but how can i get your unicode arial ttf version.

i want to try it with this ttf fonts.

and i use ttf file get from xp(simple chinese),also use gbk,it can't work properly.
Reply
#15
i have this file under c:\windows\fonts\arialuni.ttf.

-yuval
Reply

Logout Mark Read Team Forum Stats Members Help
RSS to support Chinese text code?0