I'm working on some OO PHP code to generate an RSS feed from a postgreSQL database. The data is stored in the database with special characters (eg ä, etc) as well as text containing strings wrapped in single quotes and double quotes. I've looked at hmtlentities() and htmlspecialchars() .
// Remove HTML special characters from displays.
function cleanHTMLChars()
{
return htmlspecialchars($this->text) ;
}
// Format a block of text.
function formatTextBlock()
{
//
// Trim leading and trailing spaces.
$text = trim($this->text) ;
//
// Replace HTML chars.
$text = $this->cleanHTMLChars($text) ;
//
// Replace new lines with <br>
$text = ereg_replace("\n","<br>", $text);
//
// Return our text.
return $text ;
}
So far I have drawn a blank at getting these characters displayed. For those browsers that I can see the feed, where the apostrophes should be is replaced by a ? and if they encounter a special character, such as an ä, a message saying "An invalid character was found ....".
Any help would be appreciated. I'm fairly new to PHP OO and still learning as I go, so forgive me if this sounds simple to do to some coders.
Thank you