You are here: Documentation » Frequently Asked Questions » I'm seeing weird characters
I'm seeing weird characters
This happens when you have a character set (aka “character encoding”) mismatch between SimplePie's output and the settings for your page.
By default, SimplePie outputs everything as UTF-8. To avoid display issues, you should also ensure that your web page is set to display as UTF-8. We chose UTF-8 as a default because it is a character set that contains a large number of characters from a variety of writing systems (Roman, Japanese, Chinese, Korean, Arabic, Hebrew, etc.)
How to fix it
Change your page to UTF-8
It's important that your page and SimplePie's content have the same settings, regardless of what they are. It is preferred and highly recommended that you ensure that your page is set to use UTF-8. There are three ways to fix this issue:
- Set a
<meta>
tag inside the<head>
section of your page that looks like the following:<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- Use SimplePie's handle_content_type() method to set the correct HTTP headers for you. This will also obey any set_output_encoding() setting you may have. This method only works if certain rules are followed so check out the handle_content_type() documentation page for more details.
Change SimplePie's output to match your page
This should only be used by people who understand the potential drawbacks of not using a Unicode-based character set. If this sounds like gibberish to you, don't use this method. This is not the recommended solution because of potential complexities.
- Change SimplePie's output settings to match those of your page using set_output_encoding() in conjunction with handle_content_type(). For example, if your page is set to use
Windows-1252
and you want to maintain that, you can set SimplePie to output content asWindows-1252
as well. See the set_output_encoding() documentation page for usage details.
faq/i_m_seeing_weird_characters.txt · Last modified: 2011/03/06 03:56 (external edit)