Paul
Thu Mar 20 15:48:31 CDT 2008
This is a multi-part message in MIME format.
------=_NextPart_000_0016_01C88A99.77B2B910
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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 =3D "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 =3D "[^\u0000-\u007F]"
sRemoveUnicode =3D .Replace(sAnyString, "")
End With
End Function
-Paul Randall
"S N" <uandme72@yahoo.com> wrote in message =
news:OgWpL$piIHA.4344@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=20
DataPrep =3D 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=3D"VBSCRIPT" CODEPAGE=3D"1252"%>
<HTML><HEAD>
<meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Diso-8859-1" />
<meta http-equiv=3D"Content-Language" content=3D"en-us" />
the problem is still not solved
please help
"Anthony Jones" <Ant@yadayadayada.com> wrote in message =
news:%23jGo1GRiIHA.5088@TK2MSFTNGP02.phx.gbl...
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%233n2yuBiIHA.4744@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=3D""
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.
>>
>=20
> Thanks for the vote of confidence Bob but it baffles me. ;)
>=20
> 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.
>=20
> 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.
>=20
> --=20
> Anthony Jones - MVP ASP/ASP.NET
>=20
>
------=_NextPart_000_0016_01C88A99.77B2B910
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Within VBScript strings, all characters =
are stored=20
as 16-bit Unicode values, so you can't easily tell whether your string =
contains=20
Unicode or not. Depending on how well the data was scrubbed before =
being=20
put in the database, it may contain some Unicode. Depending on how =
your=20
computer is set up, it is not obvious when you display Unicode =
characters in a=20
message box. VBScript includes a number of functions for =
interacting with=20
Unicode characters -- the W versions of things like ChrW and =
AscW.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is a short script that =
demonstrates a message=20
box displaying a string that includes a Unicode character (that looks =
something=20
like a single quote) and the same string with that character =
removed (using=20
a simple regular expression).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Dim s<BR>s =3D "Hello *" & =
ChrW(900) & "*=20
unicode"<BR>msgbox s & vbcrlf & sRemoveUnicode(s)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Function =
sRemoveUnicode(sAnyString)<BR>'Returns=20
sAnyString with all unicode [actually, all<BR>' characters outside =
the=20
range ChrW(0) to<BR>' ChrW(255)] removed. VBScript strings =
are=20
made<BR>' up of 16-bit characters so they can handle =
a<BR>' lot of=20
unicode stuff.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>With New RegExp<BR> .Pattern =3D=20
"[^\u0000-\u007F]"<BR> sRemoveUnicode =3D .Replace(sAnyString, =
"")<BR>End=20
With<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>End Function</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </DIV></FONT>
<DIV><FONT face=3DArial size=3D2>-Paul Randall</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>"S N" <<A =
href=3D"mailto:uandme72@yahoo.com">uandme72@yahoo.com</A>>=20
wrote in message <A=20
href=3D"news:OgWpL$piIHA.4344@TK2MSFTNGP03.phx.gbl">news:OgWpL$piIHA.4344=
@TK2MSFTNGP03.phx.gbl</A>...</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=3DArial size=3D2>i am attaching the sample code. =
actually i am=20
printing from a field in access database. the text entered in the =
database=20
contains single quotes and double quotes. when i try to print them =
using=20
response.write, the double quotes are getting replaced with question =
marks. i=20
have tried the method of </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>DataPrep =3D =
Replace(DataPrep, """",=20
"&quot;")</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>still problem remains.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>i also tried</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2><STRONG>response.write(server.htmlencode(myrs(3))) =
' where=20
myrs is adodb recordset</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>still the problem =
remains</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>i am also attaching the header lines =
from my asp=20
page</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><STRONG><!DOCTYPE HTML PUBLIC =
"-//W3C//DTD=20
HTML 4.01 Transitional//EN"><BR><</STRONG></FONT><A=20
href=3D'mailto:%@LANGUAGE=3D"VBSCRIPT'><FONT face=3DArial=20
size=3D2><STRONG>%@LANGUAGE=3D"VBSCRIPT</STRONG></FONT></A><FONT =
face=3DArial=20
size=3D2><STRONG>" CODEPAGE=3D"1252"%><BR></STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG></STRONG></FONT> </DIV>
<DIV><FONT face=3DArial =
size=3D2><STRONG><HTML><HEAD><BR><meta=20
http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Diso-8859-1"=20
/><BR><meta http-equiv=3D"Content-Language" content=3D"en-us"=20
/></STRONG><BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the problem is still not =
solved</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>please help</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Anthony Jones" <</FONT><A=20
href=3D"mailto:Ant@yadayadayada.com"><FONT face=3DArial=20
size=3D2>Ant@yadayadayada.com</FONT></A><FONT face=3DArial =
size=3D2>> wrote in=20
message </FONT><A =
href=3D"news:%23jGo1GRiIHA.5088@TK2MSFTNGP02.phx.gbl"><FONT=20
face=3DArial =
size=3D2>news:%23jGo1GRiIHA.5088@TK2MSFTNGP02.phx.gbl</FONT></A><FONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> =
"Bob Barrows=20
[MVP]" <</FONT><A href=3D"mailto:reb01501@NOyahoo.SPAMcom"><FONT =
face=3DArial=20
size=3D2>reb01501@NOyahoo.SPAMcom</FONT></A><FONT face=3DArial =
size=3D2>> wrote=20
in message<BR>> </FONT><A=20
href=3D"news:%233n2yuBiIHA.4744@TK2MSFTNGP06.phx.gbl"><FONT =
face=3DArial=20
size=3D2>news:%233n2yuBiIHA.4744@TK2MSFTNGP06.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...<BR>>> Daniel Crichton wrote:<BR>>> > =
&apos; and=20
&quot; are HTML entities - these are converted by web<BR>>> =
>=20
browsers into ' and " respectively.<BR>>> ><BR>>> > =
If you=20
just want to print the literal characters, that's easy =
enough:<BR>>>=20
><BR>>> > Response.Write """"<BR>>> ><BR>>> =
>=20
will print a single " (there are 4 " in that line, the two outer=20
ones<BR>>> > are the string containers, the two inners =
generate the=20
single " as<BR>>> > doubling them up inside a string turns =
them into=20
a literal instead).<BR>>> ><BR>>> > another=20
example<BR>>> ><BR>>> > Response.Write "<a=20
href=3D""</FONT><A href=3D'
http://myurl.com/apage.asp"">This'><FONT =
face=3DArial=20
size=3D2>
http://myurl.com/apage.asp"">This</FONT></A><FONT =
face=3DArial size=3D2>=20
is a<BR>>> > link</a>"<BR>>> > Notice how you =
just=20
double up the quotation marks.<BR>>> ><BR>>> > For =
an=20
apostrophe you don't need to do anything special:<BR>>> =
><BR>>>=20
> Response.Write "They're not here"<BR>>> ><BR>>> =
> So=20
what problem are you having with quotes and apostrophes?<BR>>>=20
><BR>>><BR>>> From the original post: "my code using=20
response.write replaces " character<BR>>> with =
question<BR>>>=20
mark"<BR>>><BR>>> It's most likely a codepage problem. =
I've been=20
holding back from replying<BR>> to<BR>>> this because Anthony =
typically has the most reliable advice for these<BR>>>=20
situations.<BR>>><BR>> <BR>> Thanks for the vote of =
confidence Bob=20
but it baffles me. ;)<BR>> <BR>> Since " is within the =
lower ascii=20
range 0-127 the only encoding that could<BR>> screw this up would =
be=20
UTF-16. But if the browser thought it was getting<BR>> say=20
Windows-1252 and yet the server was encoding to UTF-16 (or vice =
versa)<BR>>=20
the content would be completely garbled.<BR>> <BR>> I suspect =
that what=20
the OP thinks is happening and what actually is are very<BR>>=20
different. Like Dan says I think we would need to see some =
actual code=20
to<BR>> make sense of this.<BR>> <BR>> -- <BR>> Anthony =
Jones -=20
MVP ASP/ASP.NET<BR>> <BR>></FONT> </BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0016_01C88A99.77B2B910--