|
Prev: some users cannot open asp page or see some images on the intranet
Next: ASP with XML isn't working :-(
From: Corey Thomas - MCSE/MCSA/MCDBA on 17 Mar 2008 09:45 To print a double quote, use two double quotes. Example: Response.Write "Here is a double quote: "". " Same for single quotes, I think. -Corey "S N" wrote: > 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 > > >
From: Daniel Crichton on 17 Mar 2008 11:10 Bob wrote on Mon, 17 Mar 2008 06:43:16 -0400: > Daniel Crichton wrote: >> ' and " are HTML entities - these are converted by web >> browsers into ' and " respectively. >> If you just want to print the literal characters, that's easy enough: >> Response.Write """" >> will print a single " (there are 4 " in that line, the two outer ones >> are the string containers, the two inners generate the single " as >> doubling them up inside a string turns them into a literal instead). >> another example >> Response.Write "<a href=""http://myurl.com/apage.asp"">This is a >> link</a>" >> Notice how you just double up the quotation marks. >> For an apostrophe you don't need to do anything special: >> Response.Write "They're not here" >> So what problem are you having with quotes and apostrophes? > From the original post: "my code using response.write replaces " > character with question mark" I missed that, I'd been reading the other replies. > It's most likely a codepage problem. I've been holding back from > replying to this because Anthony typically has the most reliable > advice for these situations. Then again it could be anything without the OP supplying example code that has the problem, as it might be down to the way he's trying to print those characters (for instance, using CHR(X) and providing the wrong X value). -- Dan
From: Anthony Jones on 18 Mar 2008 12:04 "Bob Barrows [MVP]" <reb01501(a)NOyahoo.SPAMcom> wrote in message news:%233n2yuBiIHA.4744(a)TK2MSFTNGP06.phx.gbl... > Daniel Crichton wrote: > > ' and " are HTML entities - these are converted by web > > browsers into ' and " respectively. > > > > If you just want to print the literal characters, that's easy enough: > > > > Response.Write """" > > > > will print a single " (there are 4 " in that line, the two outer ones > > are the string containers, the two inners generate the single " as > > doubling them up inside a string turns them into a literal instead). > > > > another example > > > > Response.Write "<a href=""http://myurl.com/apage.asp"">This is a > > link</a>" > > Notice how you just double up the quotation marks. > > > > For an apostrophe you don't need to do anything special: > > > > Response.Write "They're not here" > > > > So what problem are you having with quotes and apostrophes? > > > > From the original post: "my code using response.write replaces " character > with question > mark" > > It's most likely a codepage problem. I've been holding back from replying to > this because Anthony typically has the most reliable advice for these > situations. > Thanks for the vote of confidence Bob but it baffles me. ;) Since " is within the lower ascii range 0-127 the only encoding that could screw this up would be UTF-16. But if the browser thought it was getting say Windows-1252 and yet the server was encoding to UTF-16 (or vice versa) the content would be completely garbled. I suspect that what the OP thinks is happening and what actually is are very different. Like Dan says I think we would need to see some actual code to make sense of this. -- Anthony Jones - MVP ASP/ASP.NET
From: S N on 20 Mar 2008 11:33 i am attaching the sample code. actually i am printing from a field in access database. the text entered in the database contains single quotes and double quotes. when i try to print them using response.write, the double quotes are getting replaced with question marks. i have tried the method of DataPrep = Replace(DataPrep, """", """) still problem remains. i also tried response.write(server.htmlencode(myrs(3))) ' where myrs is adodb recordset still the problem remains i am also attaching the header lines from my asp page <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <HTML><HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Language" content="en-us" /> the problem is still not solved please help "Anthony Jones" <Ant(a)yadayadayada.com> wrote in message news:%23jGo1GRiIHA.5088(a)TK2MSFTNGP02.phx.gbl... > "Bob Barrows [MVP]" <reb01501(a)NOyahoo.SPAMcom> wrote in message > news:%233n2yuBiIHA.4744(a)TK2MSFTNGP06.phx.gbl... >> Daniel Crichton wrote: >> > ' and " are HTML entities - these are converted by web >> > browsers into ' and " respectively. >> > >> > If you just want to print the literal characters, that's easy enough: >> > >> > Response.Write """" >> > >> > will print a single " (there are 4 " in that line, the two outer ones >> > are the string containers, the two inners generate the single " as >> > doubling them up inside a string turns them into a literal instead). >> > >> > another example >> > >> > Response.Write "<a href=""http://myurl.com/apage.asp"">This is a >> > link</a>" >> > Notice how you just double up the quotation marks. >> > >> > For an apostrophe you don't need to do anything special: >> > >> > Response.Write "They're not here" >> > >> > So what problem are you having with quotes and apostrophes? >> > >> >> From the original post: "my code using response.write replaces " character >> with question >> mark" >> >> It's most likely a codepage problem. I've been holding back from replying > to >> this because Anthony typically has the most reliable advice for these >> situations. >> > > Thanks for the vote of confidence Bob but it baffles me. ;) > > Since " is within the lower ascii range 0-127 the only encoding that could > screw this up would be UTF-16. But if the browser thought it was getting > say Windows-1252 and yet the server was encoding to UTF-16 (or vice versa) > the content would be completely garbled. > > I suspect that what the OP thinks is happening and what actually is are very > different. Like Dan says I think we would need to see some actual code to > make sense of this. > > -- > Anthony Jones - MVP ASP/ASP.NET > >
From: Paul Randall on 20 Mar 2008 16:48
Within VBScript strings, all characters are stored as 16-bit Unicode values, so you can't easily tell whether your string contains Unicode or not. Depending on how well the data was scrubbed before being put in the database, it may contain some Unicode. Depending on how your computer is set up, it is not obvious when you display Unicode characters in a message box. VBScript includes a number of functions for interacting with Unicode characters -- the W versions of things like ChrW and AscW. Here is a short script that demonstrates a message box displaying a string that includes a Unicode character (that looks something like a single quote) and the same string with that character removed (using a simple regular expression). Dim s s = "Hello *" & ChrW(900) & "* unicode" msgbox s & vbcrlf & sRemoveUnicode(s) Function sRemoveUnicode(sAnyString) 'Returns sAnyString with all unicode [actually, all ' characters outside the range ChrW(0) to ' ChrW(255)] removed. VBScript strings are made ' up of 16-bit characters so they can handle a ' lot of unicode stuff. With New RegExp .Pattern = "[^\u0000-\u007F]" sRemoveUnicode = .Replace(sAnyString, "") End With End Function -Paul Randall "S N" <uandme72(a)yahoo.com> wrote in message news:OgWpL$piIHA.4344(a)TK2MSFTNGP03.phx.gbl... i am attaching the sample code. actually i am printing from a field in access database. the text entered in the database contains single quotes and double quotes. when i try to print them using response.write, the double quotes are getting replaced with question marks. i have tried the method of DataPrep = Replace(DataPrep, """", """) still problem remains. i also tried response.write(server.htmlencode(myrs(3))) ' where myrs is adodb recordset still the problem remains i am also attaching the header lines from my asp page <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <HTML><HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Language" content="en-us" /> the problem is still not solved please help "Anthony Jones" <Ant(a)yadayadayada.com> wrote in message news:%23jGo1GRiIHA.5088(a)TK2MSFTNGP02.phx.gbl... > "Bob Barrows [MVP]" <reb01501(a)NOyahoo.SPAMcom> wrote in message > news:%233n2yuBiIHA.4744(a)TK2MSFTNGP06.phx.gbl... >> Daniel Crichton wrote: >> > ' and " are HTML entities - these are converted by web >> > browsers into ' and " respectively. >> > >> > If you just want to print the literal characters, that's easy enough: >> > >> > Response.Write """" >> > >> > will print a single " (there are 4 " in that line, the two outer ones >> > are the string containers, the two inners generate the single " as >> > doubling them up inside a string turns them into a literal instead). >> > >> > another example >> > >> > Response.Write "<a href=""http://myurl.com/apage.asp"">This is a >> > link</a>" >> > Notice how you just double up the quotation marks. >> > >> > For an apostrophe you don't need to do anything special: >> > >> > Response.Write "They're not here" >> > >> > So what problem are you having with quotes and apostrophes? >> > >> >> From the original post: "my code using response.write replaces " character >> with question >> mark" >> >> It's most likely a codepage problem. I've been holding back from replying > to >> this because Anthony typically has the most reliable advice for these >> situations. >> > > Thanks for the vote of confidence Bob but it baffles me. ;) > > Since " is within the lower ascii range 0-127 the only encoding that could > screw this up would be UTF-16. But if the browser thought it was getting > say Windows-1252 and yet the server was encoding to UTF-16 (or vice versa) > the content would be completely garbled. > > I suspect that what the OP thinks is happening and what actually is are very > different. Like Dan says I think we would need to see some actual code to > make sense of this. > > -- > Anthony Jones - MVP ASP/ASP.NET > > |