FROM : Norman Gray
DATE : Fri Jul 21 00:13:50 2006
On 2006 Jul 20 , at 18.18, David Dunham wrote:
>>>> I'm trying to output a string suitable for using in HTML -- no
>>>> troublesome characters like < and >.
and later:
> the actual intent is to use within XML not HTML. So maybe I should
> remove "xml" from the exclusions and it will handle " ?
There's no need to encode " in XML either. The only characters that
need to be escaped in XML (or HTML) body content are < and &.
Even > doesn't have to be escaped -- it's only there for
symmetry. You don't even have to escape non-ASCII characters, since
XML files are Unicode.
Or are you trying to escape the string for use within an attribute
value? In that case you will additionally have to escape ' or "
unless you're using the other one as the attribute value delimiter,
but the suggested (by the spec) ' and " aren't defined by
the spec. Having elaborate strings in attributes is probably a poor
idea, but if you didn't design the DTD, you're stuck with it.
All the best,
Norman
--
------------------------------------------------------------------------
----
Norman Gray / http://nxg.me.uk
eurovotech.org / University of Leicester, UK
DATE : Fri Jul 21 00:13:50 2006
On 2006 Jul 20 , at 18.18, David Dunham wrote:
>>>> I'm trying to output a string suitable for using in HTML -- no
>>>> troublesome characters like < and >.
and later:
> the actual intent is to use within XML not HTML. So maybe I should
> remove "xml" from the exclusions and it will handle " ?
There's no need to encode " in XML either. The only characters that
need to be escaped in XML (or HTML) body content are < and &.
Even > doesn't have to be escaped -- it's only there for
symmetry. You don't even have to escape non-ASCII characters, since
XML files are Unicode.
Or are you trying to escape the string for use within an attribute
value? In that case you will additionally have to escape ' or "
unless you're using the other one as the attribute value delimiter,
but the suggested (by the spec) ' and " aren't defined by
the spec. Having elaborate strings in attributes is probably a poor
idea, but if you didn't design the DTD, you're stuck with it.
All the best,
Norman
--
------------------------------------------------------------------------
----
Norman Gray / http://nxg.me.uk
eurovotech.org / University of Leicester, UK
| Related mails | Author | Date |
|---|---|---|
| David Dunham | Jul 20, 06:25 | |
| Douglas Davidson | Jul 20, 18:36 | |
| David Dunham | Jul 20, 19:18 | |
| Douglas Davidson | Jul 20, 20:12 | |
| Peter Bierman | Jul 20, 20:41 | |
| Norman Gray | Jul 21, 00:13 | |
| David Dunham | Jul 21, 00:26 | |
| Norman Gray | Jul 21, 11:40 |






Cocoa mail archive

