Skip navigation.
 
mlRe: Encoding a string for HTML
FROM : Norman Gray
DATE : Fri Jul 21 11:40:00 2006

David, hello.

On 2006 Jul 20 , at 23.26, David Dunham wrote:

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


That's a bug!  But it sounds as if you're stuck with an app's 
peculiarities: good luck!

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


Not elaborate indeed.  This is an echo of a religious war (twenty 
years old and still healthy) about attributes vs. content.  One 
potential rule of thumb would be that if text needs any escaping at 
all, then one should think twice and thrice about it being in an 
attribute.  But as I say, it's a doctrinal matter, and in any case it 
doesn't sound like you've got any choice....

All the best,

Norman


--
------------------------------------------------------------------------
----
Norman Gray  /  http://nxg.me.uk
eurovotech.org  /  University of Leicester, UK

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