How to display ISO-8859-1 RSS correct

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
mgrendal

How to display ISO-8859-1 RSS correct

Post by mgrendal »

How can I display a ISO-8859-1 RSS correctly on my site? The norwegian characters come out garbled...
mgrendal

Re: How to display ISO-8859-1 RSS correct

Post by mgrendal »

I have tried manipulating both rss_parse.inc (UTF-8 ISO-8859-1 options) and .htaccess (iconv and mbstring values), but nothing helps... Any ideas anyone?
cyberman

Re: How to display ISO-8859-1 RSS correct

Post by cyberman »

Hmm, the default CMSms output is utf-8 (see config.php). If you define ISO-8859-1 for front- and backend it should work ...
mgrendal

Re: How to display ISO-8859-1 RSS correct

Post by mgrendal »

Yes, I know that would work - but I thought it was not recommended (slowdowns...)? I actually tried it once, and found that some of the menues in admin (eg. language selector) was displaying garbled norwegian characters - or maybe I missed a setting for that?

So, switching to ISO-8859-1 for my site is the only option?
Piratos

Re: How to display ISO-8859-1 RSS correct

Post by Piratos »

With my smarty plugin pirss i have done it so:

Code: Select all

  $url = isset($params['url']) ? $params['url'] : 'http://news.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml';
  $encoding = isset($params['encoding']) ? $params['encoding'] : '';
  $max_news = isset($params['maxnews']) ? $params['maxnews'] : 10;
  $data = implode('', @file($url));
  $outar=array();
  $io=-1;
  if ($data)
  {
     if ($encoding && function_exists('mb_convert_encoding')) {$data = mb_convert_encoding($data, $encoding, 'auto');}


[gelöscht durch Administrator]
Last edited by Piratos on Wed Sep 27, 2006 7:04 pm, edited 1 time in total.
Piratos

Re: How to display ISO-8859-1 RSS correct

Post by Piratos »

If you have problems with auto you can hardcoded:
mb_convert_encoding($data, 'utf-8', 'iso-8859-1')
utf-8  = to 

iso-8859  from
mgrendal

Re: How to display ISO-8859-1 RSS correct

Post by mgrendal »

Thank you so much, I got pirss to work! I just had to make two adjustments:

Code: Select all

Line 5:
From
  $encoding = isset($params['encoding']) ? $params['endcoding'] : '';
To
  $encoding = isset($params['encoding']) ? $params['encoding'] : '';

Line 12:
From
  if ($encoding && function_exists('mb_convert_encoding')) {$data = mb_convert_encoding($data, $encoding, 'auto');}
To
  if ($encoding && function_exists('mb_convert_encoding')) {$data = mb_convert_encoding($data, $encoding, 'ISO-8859-1');}
The only thing I noticed now is a dash presented as a square - is that a known issue?
Piratos

Re: How to display ISO-8859-1 RSS correct

Post by Piratos »

Code: Select all

endcoding
This was a known issue but pirss is out of support.
Piratos

Re: How to display ISO-8859-1 RSS correct

Post by Piratos »

is that a known issue
Some feeds make chars hardcoded as example  &#244  - i mean that mb_convert_encoding does not work with this.

But you can replace it before you are using .
mgrendal

Re: How to display ISO-8859-1 RSS correct

Post by mgrendal »

Is there a list of what should be replaced? And how do I make the replacement?
Piratos

Re: How to display ISO-8859-1 RSS correct

Post by Piratos »

Code yxou can see here http://en.selfhtml.org/html/referenz/ze ... _iso8859_1

In cases the unicode did not work you can change it with as example

$data=str_replace('unicode','html- name',$data);

look in the source of your html code and see what chars are bad and only take this , because it costs time to replace all.
mgrendal

Re: How to display ISO-8859-1 RSS correct

Post by mgrendal »

Thanks, I was able to replace the weird looking dash by copying the character from the original RSS feed i Opera, and then pasting it into the code in Textpad - displayed in Textpad as a kind of a box... I haven't been able to find any value for this character, but this method works...
avegard
Forum Members
Forum Members
Posts: 12
Joined: Sun Oct 08, 2006 10:32 am

Re: How to display ISO-8859-1 RSS correct

Post by avegard »

It is interesting to read the above, because I will also be using norwegian characters. I am making a site for our library and we have feeds on new books, films cd's etc. that we loan. Anyhow, I could not get this pirss installed. I tried uploading the folder to the modules folder, but it was not detected in the module installation in admin. So,... is there some other sort of way to install it? Where should the php file go?

Regards,
Vegard
Piratos

Re: How to display ISO-8859-1 RSS correct

Post by Piratos »

Pirss is a normal smarty plugin not a module.

Put it in the lib/smarty/plugins folder and the template in tmp/templates.
avegard
Forum Members
Forum Members
Posts: 12
Joined: Sun Oct 08, 2006 10:32 am

Re: How to display ISO-8859-1 RSS correct

Post by avegard »

Thanks for explaining how to use the PIrss, it works. But I tried the above stuff but still get gibberish characters on the special norwegian letters. Therefore, could you give an example of how you would use this particular code?
$data=str_replace('unicode','html- name',$data);
Piratos wrote: Code yxou can see here http://en.selfhtml.org/html/referenz/ze ... _iso8859_1

In cases the unicode did not work you can change it with as example

$data=str_replace('unicode','html- name',$data);

look in the source of your html code and see what chars are bad and only take this , because it costs time to replace all.
Locked

Return to “CMSMS Core”