Re: Problem with special char in MySQL and XML [message #174849 is a reply to message #174847] |
Wed, 13 July 2011 12:42 |
Michael Fesser
Messages: 215 Registered: September 2010
Karma:
|
Senior Member |
|
|
.oO(Sarah)
> I try to resume, for try to find my error.
>
> I've a DB with UTF_8 encode
>
> I've saved char as & è à ' ì
> is this OK?? Or Do I've save char with this ecode &(space)amp;
> etcc....??? I mean: can I use è à ò ù & in my UTF_8 DB Table???
Yes, that's what UTF-8 is for. You can (and should!) store every char
literally and _not_ as character references like the &-thing.
> Now I've to read from table and show results in XML. Do I've to change
> results that I've in DB, or keep in my format?
XML uses UTF-8 by default, so you can directly output your text. But
there's still a handful of special characters that need to be written as
entity references, for example the ampersand '&'. If this char appears
unescaped in your text, it will break your XML.
In your code example from your first posting there was something like:
… strip_tags(utf8_encode(…))
I don't think either of them is necessary. Take your DB data, pass it
through htmlspecialchars() and take the result to build your XML.
Micha
|
|
|