The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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 [&ldquo;] or right angular double quotes [&ldquo;] and replace them with straight double quotes [&quot;].

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

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, "”", "&quot;")

I hope were talking about the same quotes here, as I never really knew their official name.

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.

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 .