SimplePie 1.5 is now available!

SimplePie Documentation.  Learn how to use this thing.  It's way better than going to school.

You are here: Documentation » API Reference » SimplePie » set_output_encoding()

set_output_encoding()

Description

class SimplePie {
	set_output_encoding ( [string $encoding = 'UTF-8'] )
}

Allows you to override SimplePie's output to match that of your webpage. This is useful for times when your webpages are not being served as UTF-8. This setting will be obeyed by handle_content_type(), and is similar to set_input_encoding().

It should be noted, however, that not all character encodings can support all characters. If your page is being served as ISO-8859-1 and you try to display a Japanese feed, you'll likely see garbled characters. Because of this, it is highly recommended to ensure that your webpages are served as UTF-8.

The number of supported character encodings depends on whether your web host supports mbstring, iconv, or both. See Supported Character Encodings for more information.

Availability

  • Available since SimplePie 1.0.
  • Previously existed as output_encoding() since Beta 3.

Parameters

encoding

The character encoding to serve SimplePie's output as.

Examples

Override SimplePie's output

$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
$feed->set_output_encoding('Windows-1252');
$feed->init();
$feed->handle_content_type();
echo $feed->get_title();

See Also


reference/simplepie/set_output_encoding.txt · Last modified: 2011/03/06 03:56 (external edit)