SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Also available in Large Si's Avatar
    Join Date
    Sep 2002
    Location
    Walsall, UK
    Posts
    1,911
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting/stripping non-ASCII characters

    It's been a while since I had an ASP problem I couldn't solve but here goes...

    I'm trying to catch some characters in a string before they are entered into a database that are not ASCII and convert them to ASCII characters. The characters in question are the angular double quotes but this could be associated with similar occurences. I want to check for left angular double quotes [“] or right angular double quotes [“] and replace them with straight double quotes ["].

    (I'm not actually storing the HTML equivalents - they are simply there to give you an idea of which characters I'm on about.)

    Does anyone know of a way of catching these buggers? I've tried using chr(8220) (the numeric code for one of the illegal characters apparently) but ASP has a problem working with numbers outside the character map.

    Cheers!
    Si
    Are you a Photoshop Jedi Master? Prove it!

    Is funky house your bag? You'll love this!

    Voice
    , eyes, ears, body and hands.


  2. #2
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Funny you should ask. I ran into this same problem about 2 weeks ago. You can actually just paste the quote right into your ASP script with a REPLACE and it will take care of them. I tried using the ASCII value as well with no luck:

    Code:
    myvar = REPLACE(myvar, "", """)
    I hope were talking about the same quotes here, as I never really knew their official name.

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Off Topic:

    Man I haven't done an ASP post in a while!

    The code below should replace the characters:
    Code:
    'opening double quotes
    myvar = replace(myvar, chr(147), chr(34))
    'closing double quotes
    myvar = replace(myvar, chr(148), chr(34))
    For future reference, you can open up charmap.exe and check the "Advanced View" checkbox to view more characters. In this case, you might want to look at the "Windows: Western" character set (the default in charmap is "Unicode"), since that's probably your server's default.
    Quote Originally Posted by Thing
    I hope were talking about the same quotes here, as I never really knew their official name.
    That would be an "opening double quote" and "closing double quote" if you're talking about the example you posted .

  4. #4
    Also available in Large Si's Avatar
    Join Date
    Sep 2002
    Location
    Walsall, UK
    Posts
    1,911
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers guys! I didn't realise I could just paste the characters into my ASP script. I'll give both methods a try.
    Si
    Are you a Photoshop Jedi Master? Prove it!

    Is funky house your bag? You'll love this!

    Voice
    , eyes, ears, body and hands.


  5. #5
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    That would be an "opening double quote" and "closing double quote" if you're talking about the example you posted .
    We were calling them "fancy quotes"

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Thing
    We were calling them "fancy quotes"
    http://alistapart.com/articles/emen/

    More about typography than you'd ever want to know


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •