|
Posted by lawrence k on 11/09/07 07:29
On Nov 8, 1:02 am, Toine <bapo...@gmail.com> wrote:
> Hello,
>
> My problem:
> I'm using PHP to dynamically create an XML document. However, some of
> my data (from MySQL) contains non-UTF characters such as the umlaut.
> Naturally, browsers like IE 7 throw an error when attempting to parse
> these characters. I understand that these characters are invalid for
> XML.
>
> My question:
> What is the best to handle these characters when creating XML
> documents on the fly? It seems like searching and replacing these
> characters would be complicated, and there must be an easier way.
If you're only trying to communicate plain text, you can wrap your
text in a CDATA block. Or you can do a lot of str_replace() to change
them all to HTML entities.
If the problem is that your XML is outputting things that your users
input, and your users are inputting a lot of junk, then all you can do
is filter out the non-UTF8 stuff. seems_utf8 can be a help, and is
mentioned on this page:
http://wordpress.taragana.net/nav.html?_functions/index.html
[Back to original message]
|