ASP Escape Character

Is there an escape character/symbol in ASP such as { \ } used in PHP for things like quotes, apostrophes, etc.

Don S.

not as far as i know, what exactly do you want to do? i can write u a function to do it :slight_smile:

Here was the question to the list I run (a list that doesn’t deal much in ASP). You might like to email the guy and ask.

Hi members,
please advise how to escape fluency of special symbols (apostrophes,
quotation marks) on asp code?


Stanislav Rabinovich

OK. If you are in a string, then a double double quote will escape it. Single quotes do not need escaping within a string… When you just want to send a quote, use three quotes…

Ex.
Invalid
str = " She said “Hello World” to the whole group"

valid
str = " She said ““Hello World”” to the whole group"

valid
str = " She said "“Hello " & name & “””

The other time escape characters are used is when you’re writing a SQL string to interact with the database. SQL uses single quotes to delimit strings, and uses a pair of single quotes (that’s two ’ characters) to escape them.

This isn’t anything to do with ASP itself, but obviously you need to write these escape sequences in your ASP.

So say you were writing a piece of SQL to query a database and wanted all the records where last name was “O’Toole”. The SQL you’d need would be

SELECT * FROM TABLE_NAME WHERE LAST_NAME = 'O''Toole'

As I say this isn’t strictly an ASP answer as it’s an escape sequence in SQL itself, but obviously a lot of SQL is often embedded in ASP pages so it’s half-relevant here :).