468,768 Members | 1,684 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,768 developers. It's quick & easy.

printing character ' and " in asp using vbscript

S N
how to print apostrophe character ' and double quote " in asp using
vbscript.
my code using response.write replaces " character with inverted question
mark.
please help
Mar 16 '08 #1
11 4526
S N
how to print apostrophe character ' and double quote " in asp using
vbscript. my code using response.write replaces " character with question
mark.
please help
Mar 16 '08 #2
'************************************************* *****************
Function DataPrep(strText)
'
'PURPOSE: prep data text entry
'
'PARAMETERS: strText -- text string to modify
'************************************************* *****************
If NOT isNull(strText) then

DataPrep = Replace(strText, ";", "")
DataPrep = Replace(DataPrep, "'", "'")
DataPrep = Replace(DataPrep, """", """)
DataPrep = Replace(DataPrep, "<", "&lt;")
DataPrep = Replace(DataPrep, ">", "&gt;")

End if

End Function


"S N" <ua******@yahoo.comwrote in message news:OC**************@TK2MSFTNGP05.phx.gbl...
how to print apostrophe character ' and double quote " in asp using vbscript.
my code using response.write replaces " character with inverted question mark.
please help


Mar 16 '08 #3
Jon Paal [MSMD] wrote:
'************************************************* *****************
Function DataPrep(strText)
'
'PURPOSE: prep data text entry
'
'PARAMETERS: strText -- text string to modify
'************************************************* *****************
If NOT isNull(strText) then

DataPrep = Replace(strText, ";", "")
DataPrep = Replace(DataPrep, "'", "&apos;")
DataPrep = Replace(DataPrep, """", "&quot;")
DataPrep = Replace(DataPrep, "<", "&lt;")
DataPrep = Replace(DataPrep, ">", "&gt;")

End if

End Function
??
What's wrong with

Response.Write Server.HTMLEncode(strText)

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mar 16 '08 #4
"Dataprep" type function allows for customization, otherwise nothing wrong with your suggested solution...
Mar 17 '08 #5
Jon Paal [MSMD] wrote on 17 mrt 2008 in
microsoft.public.inetserver.asp.general:
"Dataprep" type function allows for customization, otherwise nothing
wrong with your suggested solution...
whose?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 17 '08 #6
where to get the values of constants like &apos and &quot
also i want to replace single " and not double ""

please advise

"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot comwrote in message
news:13*************@corp.supernews.com...
'************************************************* *****************
Function DataPrep(strText)
'
'PURPOSE: prep data text entry
'
'PARAMETERS: strText -- text string to modify
'************************************************* *****************
If NOT isNull(strText) then

DataPrep = Replace(strText, ";", "")
DataPrep = Replace(DataPrep, "'", "&apos;")
DataPrep = Replace(DataPrep, """", "&quot;")
DataPrep = Replace(DataPrep, "<", "&lt;")
DataPrep = Replace(DataPrep, ">", "&gt;")

End if

End Function


"S N" <ua******@yahoo.comwrote in message
news:OC**************@TK2MSFTNGP05.phx.gbl...
>how to print apostrophe character ' and double quote " in asp using
vbscript.
my code using response.write replaces " character with inverted question
mark.
please help



Mar 17 '08 #7
The solutions provided work for others. The problem you have is not an ASP problem per se.

I suspect you will need to look elsewhere in your database/server/browser to find the problem.

I suggest you start debugging by allowing the page to be viewed by someone else with another browser so you can start eliminating
variables.

Narrow down the problem to where it can be isolated and then you may be able to resolve this matter.
Mar 24 '08 #8
S N
which group should i consult. please help

"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot comwrote in message
news:13*************@corp.supernews.com...
The solutions provided work for others. The problem you have is not an
ASP problem per se.

I suspect you will need to look elsewhere in your database/server/browser
to find the problem.

I suggest you start debugging by allowing the page to be viewed by someone
else with another browser so you can start eliminating variables.

Narrow down the problem to where it can be isolated and then you may be
able to resolve this matter.

Mar 24 '08 #9
I would start here:

microsoft.public.scripting.vbscript
Mar 24 '08 #10
"S N" <ua******@yahoo.comwrote in message
news:uC**************@TK2MSFTNGP04.phx.gbl...
which group should i consult. please help
This as good a group as any to get help with this issue.

My current guess is that the data has been entered by a Form post via ASP.
In correct codepage settings have corrupted the data entered into the DB.
--
Anthony Jones - MVP ASP/ASP.NET

Mar 24 '08 #11

"S N" <ua******@yahoo.comwrote in message
news:OI****************@TK2MSFTNGP05.phx.gbl...
>As Anthony said, if you are entering html code into the database with the
idea that this takes effect when you pull it back to a web page, you do
not
want to server.htmlencode it. Since you are using a Rich Text Editor, I
am
assuming that this will apply html tags to the text on entry, and you
want
them to act on the output.

What you really want to do is to make sure no javascript or clientside
vbscript gets injected. One way to do this is just to reject any input
that
contains the string "<script>" in it during your server-side validation.

--
Mike Brind
Microsoft MVP - ASP/ASP.NET


you have guessed it very correctly that i am entering html code into the
database (like table tags <td <trin particular) with the
idea that this takes effect when it is pulled back to a web page, and
hence i dont want to server.htmlencode it.

can you suggest a server side validation script which does as indicated
below by you. else can you suggest an alternate method of achieving
the above (ensuring the table tags get translated into tables on the
client side).
'input is the posted content from the Rich Text Editor

If InStr(input, "<string>") 0 Then
'reject it
Else
'process it
End If

--
Mike Brind
Microsoft MVP - ASP/ASP.NET
Jun 27 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

42 posts views Thread by Prashanth Badabagni | last post: by
25 posts views Thread by mdh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.