Removing obscure chars
am 03.04.2007 19:16:55 von YobboHi All
I have an ASP function in place to strip invalid chars out of a data store
before I create an XML file of this data, but my function doesn't work on a
certain set of chars.
As far as I can see these are the following:
a) trademark char
b) long hyphen/dash char
c) smart/curly quotes (both left and right)
Even though my function is set up as follows:
Function ReFormatStringForXML(s)
IF LEN(s) > 0 AND NOT IsNull(s) THEN
s = Replace(s,"™","™")
s = Replace(s,"—","-")
s = Replace(s,"’",""")
s = Replace(s,"'",""")
s = Replace(s,"""",""")
s = Replace(s,"&","&")
s = Replace(s,"<","<")
s = Replace(s,">",">")
END IF
ReFormatStringForXML = s
End Function
These chars still pass by and foul up my XML file.
I have a feeling that its down to the fact that my function is looking for
the html equiv rather than the actual char, but I can't possibly get away
with simply copy and pasting these friggin(!!) chars into my function.
Surely this is bad practise?
Does anybody know how I can trap and replace/remove these chars if need be?
Thanks