Removing obscure chars

Discussion in 'ASP General' started by Yobbo, Apr 3, 2007.

  1. Yobbo

    Yobbo Guest

    Hi 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,"<","&lt;")
    s = Replace(s,">","&gt;")
    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
    Yobbo, Apr 3, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bruce
    Replies:
    6
    Views:
    826
    Simon Forman
    Jul 4, 2006
  2. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,281
    Tim Rentsch
    Sep 23, 2005
  3. Hongyu
    Replies:
    9
    Views:
    897
    James Kanze
    Aug 8, 2008
  4. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    223
    Dan Rogers
    Nov 16, 2004
  5. Yobbo

    Removing obscure chars

    Yobbo, Apr 3, 2007, in forum: ASP General
    Replies:
    3
    Views:
    107
    Anthony Jones
    Apr 5, 2007
Loading...

Share This Page