[OSM-dev] Escaping special characters when writing tags in OSM files with osm-subset.pl & write.pm

Jon Burgess jburgess at uklinux.net
Sun Nov 5 23:07:32 GMT 2006


On Sun, 2006-11-05 at 22:27 +0000, Dean Earley wrote:
>  From memory, & SHOULDN'T be escaped in XML files.
> I was surprised when I read this but it fixed my RSS feed.. :)
> 

That doesn't seem to make sense to me since you have to escape the
character used for escaping. Otherwise encoding and decoding would not
be reversible, e.g.

(I've added some spaces just in case your client sees these as HTML...)
Encoding:    & quot ; 
would give:  & quot ; 
but decoding this would incorrectly give "

Hence this input needs to be encoded as: & amp ; quot ; 
to give the correct decoded output: & quot ; 

There are plenty of examples in planet.osm of & amp ; being used:
    <tag k="name" v="Library & amp ; Community Centre" />
    <tag k="name" v="The Waggon & amp ; Horses" />



	Jon

	





More information about the dev mailing list