1
kalamata
Headlines
  • 2005/3/25 22:55

  • kalamata

  • Not too shy to talk

  • Posts: 121

  • Since: 2005/3/3 1


Dear All,

I am using the XHLD module for generating headlines and I am faced with the following problem: I am pulling headlines from a Greek site using utf-8 encoding, a couple of other Greek sites using Greek (Windows) or Greek (ISO) as their encoding of choice and BBC and CNN using Western European.

When I load up the page, English characters load up fine. However, the others appear as questionmarks. I tried setting the charset to ISO 8859-7 for Greek ISO but that messed up all the headlines (including the Greek ones).

Is there a way of specifying what encoding is to be used for every block so that the user will not have to go through the View->Change Encoding experience?

I look forward to hearing from you soon.

Thanks in advance.

George

2
jdseymour
Re: Headlines

Have you tried auto-detection option instead of specifying a charset when creating or editing a headline?

3
kalamata
Re: Headlines
  • 2005/3/27 16:40

  • kalamata

  • Not too shy to talk

  • Posts: 121

  • Since: 2005/3/3 1


I did, but no luck at all. Any suggestions?

4
LazyBadger
Re: Headlines

1. Did you modify headlinerenderer.php in lang/<yourlanguage> folder of XHLD and add needed charsets?
2. Does your PHP have iconv support?

1-st is most important part (and described in readme, AFAIR)

5
kalamata
Re: Headlines
  • 2005/4/13 12:55

  • kalamata

  • Not too shy to talk

  • Posts: 121

  • Since: 2005/3/3 1


Hi,

Is the language/english folder for the xhld module? I could only find a headlinerenderer_sample.php class there but a headlinerenderer.php was under the class directory of the module. Is that the one I am supposed to change?

Thanks,
George

6
LazyBadger
Re: Headlines

If your site's language is English, but you want use Greek charset in feeds - rename headlinerenderer_sample.php into headlinerenderer.php, add (edit) this file by adding needed charsets in convertToUtf8 function, using current switch-statement as guide

7
kalamata
Re: Headlines
  • 2005/4/14 11:09

  • kalamata

  • Not too shy to talk

  • Posts: 121

  • Since: 2005/3/3 1


This is the code for headlinerendere.php (essentially, I only modified the latest bit).

if( ! class_exists( 'XhldRendererLocal' ) ) {
class XhldRendererLocal extends XhldRenderer
{
function XhldRendererLocal( &$headline , $mydirname='xhld0' )
{
parent::XhldRenderer( $headline , $mydirname ) ;
}

function convertFromUtf8(&$value, $key)
{
if( ! is_string( $value ) ) return ;
if( stristr( _CHARSET , 'iso-8859-1' ) ) {
$value = utf8_decode( $value ) ;
} else if( $this->_hl->getVar('headline_encoding') == 'iso-8859-1' && ! $this->_hl->getVar('headline_allowhtml') ) {
$value = htmlentities( utf8_decode( $value ) ) ;
} else {
$value = iconv( "UTF-8" , "WINDOWS-1253" , $value ) ;
}
}

function &convertToUtf8(&$xmlfile)
{
$encoding = $this->_hl->getVar('headline_encoding') ;

// auto detection
if( empty( $encoding ) ) {
$top_of_xml = substr( $xmlfile , 0 , 255 ) ;
preg_match( "/^<\?xml .* encoding=['\"]?([0-9a-z_-]+)/i", $top_of_xml , $regs ) ;
if( empty( $regs ) ) {
$encoding = 'utf-8' ;
} else {
$encoding = strtolower( $regs[1] ) ;
}
$this->_hl->setVar( 'headline_encoding' , $encoding ) ;
$headline_handler =& xoops_getmodulehandler('headline', $this->_mydirname);
$headline_handler->insert($this->_hl);
}

switch( strtolower( $encoding ) ) {
case 'iso-8859-1' :
$xmlfile = utf8_encode( $xmlfile ) ;
break ;
case 'windows-1253' :
$xmlfile = iconv( "WINDOWS-1253" , "UTF-8" , $xmlfile ) ;
break ;
case 'iso-8859-7' :
$xmlfile = iconv( "ISO-8859-7" , "UTF-8" , $xmlfile ) ;
break ;
case 'utf-8' :
default :
break ;
}

return $xmlfile;
}
}
}
?>

Is there anything I obviously did wrong?

Does my site language have to be utf-8?


The headlines have been defined as define('_AM_ENCODINGS','utf-8:UTF-8|iso-8859-1:ISO-8859-1|us-ascii:US-ASCII|windows-1253:WINDOWS-1253|iso-8859-7:ISO-8859-7') ;

Any way I can check whether the variables FOR_XOOPS_LANG_CHECKER and _AM_DBUPDATED are defined?

Thanks,
George

Login

Who's Online

98 user(s) are online (58 user(s) are browsing Support Forums)


Members: 0


Guests: 98


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits