Skip navigation.
 
mlRe: Encoding a string for HTML
FROM : David Dunham
DATE : Fri Jul 21 00:26:46 2006

On 20 Jul 2006, at 15:13, Norman Gray wrote:

> 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.


I was having trouble with one app apparently ignoring the UTF-8-ness 
of the file, so I'm now escaping non-ASCII.

> 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.


Yeah, it's an XML attribute, not mine: text="stringThatWasEncoded". 
(I wouldn't call allowing quotes and apostrophes elaborate...)

I think your explanation is telling me that I'm not going to get any 
standard routine to do this for me. I think I have a workable 
solution between dataFromRange:... and replaceOccurrencesOfString:... 
so I'll move on.

David Dunham    A Sharp, LLC
Voice/Fax: 206 783 7404    http://a-sharp.com
"People seem to misinterpret complexity as sophistication" -- Niklaus 
Wirth

Related mailsAuthorDate
mlEncoding a string for HTML David Dunham Jul 20, 06:25
mlRe: Encoding a string for HTML Douglas Davidson Jul 20, 18:36
mlRe: Encoding a string for HTML David Dunham Jul 20, 19:18
mlRe: Encoding a string for HTML Douglas Davidson Jul 20, 20:12
mlRe: Encoding a string for HTML Peter Bierman Jul 20, 20:41
mlRe: Encoding a string for HTML Norman Gray Jul 21, 00:13
mlRe: Encoding a string for HTML David Dunham Jul 21, 00:26
mlRe: Encoding a string for HTML Norman Gray Jul 21, 11:40