Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
problem with accents with rss feeds
Old 11-06-2005, 03:56 PM problem with accents with rss feeds
Novice Talker

Posts: 6
Trades: 0
Hi,

on my site I use rss feeds. I have problem with words that have accents, they are displayed wrong:



The carset I use should be fine:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

So where is the problem?
alida is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-06-2005, 08:26 PM
Average Talker

Posts: 20
Location: Benevento
Trades: 0
You need to check the encoding that you are using for the feeds data.
It seems like utf-8 text rendered with iso-8859-1 (as you have specified as encoding).
__________________

Please login or register to view this content. Registration is FREE
j2be is offline
Reply With Quote
View Public Profile Visit j2be's homepage!
 
Old 11-07-2005, 03:16 AM
Novice Talker

Posts: 6
Trades: 0
The code of the script is here, what should I change or add?

Code:
<marquee scrollamount = 2 width = 250 onmouseover="stop();" onmouseout="start();">
<?php

set_time_limit(0);
$nbsp = " ";
//The file below is the source xml file, this is the only thing you need change if you want to change source
$file = "http://www.gazzetta.it/rss/Basket.xml";

$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;

function startElement($parser, $name, $attrs) {
   	global $rss_channel, $currently_writing, $main;
   	switch($name) {
   		case "RSS":
   		case "RDF:RDF":
   		case "ITEMS":
   			$currently_writing = "";
   			break;
   		case "CHANNEL":
   			$main = "CHANNEL";
   			break;
   		case "IMAGE":
   			$main = "IMAGE";
   			$rss_channel["IMAGE"] = array();
   			break;
   		case "ITEM":
   			$main = "ITEMS";
   			break;
   		default:
   			$currently_writing = $name;
   			break;
   	}
}

function endElement($parser, $name) {
   	global $rss_channel, $currently_writing, $item_counter;
   	$currently_writing = "";
   	if ($name == "ITEM") {
   		$item_counter++;
   	}
}

function characterData($parser, $data) {
	global $rss_channel, $currently_writing, $main, $item_counter;
	if ($currently_writing != "") {
		switch($main) {
			case "CHANNEL":
				if (isset($rss_channel[$currently_writing])) {
					$rss_channel[$currently_writing] .= $data;
				} else {
					$rss_channel[$currently_writing] = $data;
				}
				break;
			case "IMAGE":
				if (isset($rss_channel[$main][$currently_writing])) {
					$rss_channel[$main][$currently_writing] .= $data;
				} else {
					$rss_channel[$main][$currently_writing] = $data;
				}
				break;
			case "ITEMS":
				if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
					$rss_channel[$main][$item_counter][$currently_writing] .= $data;
				} else {
					$rss_channel[$main][$item_counter][$currently_writing] = $data;
				}
				break;
		}
	}
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
	die("could not open XML input");
}

while ($data = fread($fp, 4096)) {
	if (!xml_parse($xml_parser, $data, feof($fp))) {
		die(sprintf("XML error: %s at line %d",
					xml_error_string(xml_get_error_code($xml_parser)),
					xml_get_current_line_number($xml_parser)));
	}
}
xml_parser_free($xml_parser);

// output HTML
//To edit the number that will be displayed change the count($rss_channel["ITEMS"]) below to the number you want eg $numbertodisplay = 10;
$numbertodisplay = count($rss_channel["ITEMS"]);

if (isset($rss_channel["ITEMS"])) {
	if (count($rss_channel["ITEMS"]) > 0) {
		for($i = 0;$i < $numbertodisplay;$i++) {
			if (isset($rss_channel["ITEMS"][$i]["LINK"])) {

//This is the actual line for displaying each item (below)
			print ("-&nbsp;<a target='_blank' href=\"" . $rss_channel["ITEMS"][$i]["LINK"] . "\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
			} 		}
	} else {
		print ("<b>There are no articles in this feed.</b>");
	}
}

?>

</marquee>
alida is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to problem with accents with rss feeds
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19572 seconds with 12 queries