Re: printing character ' and " in asp using vbscript

This is a multi-part message in MIME format.

------=_NextPart_000_0022_01C89825.DE08F500
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable

i have checked the access database. when i open the access table, there =
also i am finding the rectangular block whereever i expect apostrophe .

also i have started using server.htmlencode for retrieving values from =
the database. but it displays the new line characters and paragraph =
characters (<BR> and <p> notations) stored in the text field as such. =
meaning instead of using these characters as commands for new line it is =
displaying them as it is, ie as "<BR>" and "<p>". in this way the =
paragraph boundaries has gone.

please help me with the above two problems.

"Paul Randall" <paulr901 [at] cableone.net> wrote in message =
news:OOTWT7fjIHA.4320 [at] TK2MSFTNGP06.phx.gbl...
Thanks for posting one of your problematic characters. I think one of =
the problems is that a number of distinct concepts, such as charset, =
font, and locale, are being blurred together. At first you mentioned =
having problems with the single and double quote characters, and defined =
them as apostrophe character ' and double quote ". Recently you posted =
the =E2=80=98 character, which I assume is what you meant by an =
apostrophe character. It certainly looks a lot like what I would call a =
single quote, but if you put my single quote ('), and your single quote =
together, you can see that they are different: (=E2=80=98'). Well, =
maybe you can see the difference, and maybe you can't. It all depends =
on what font the characters are being displayed in. I think in general, =
if a font does not contain a glyph for a character, then it displays a =
square or rectangular box for that character. I think most fonts =
contain glyphs for all characters in the range Chr(32) to Chr(127). =
Many fonts contain glyphs for characters in the range Chr(128) to =
Chr(255) too. Many fonts also include glyphs for some characters in the =
range ChrW(256) to ChrW(65535), which are Unicode characters. My =
knowledge of Unicode is limited, so some of my terminology may not be =
technically correct, and I would appreciate being corrected.

Copy the code below into a .vbs file and run it. You will get two =
message boxes. The first message box will contain two lines:

Hello *'=CE=84=E2=80=98* Unicode
=CE=84=E2=80=98

The first line contains a mixture of what might be considered Unicode =
and non-Unicode characters. The three characters between the asterisks =
(*) might all be considered single quotes, but only the first one is =
Chr(39), the character I consider a single quote. The second one is =
ChrW(900), and the third one is your single quote, ChrW(8216).

The second line displays what is left of the first line after removing =
all characters whose AscW value is less than 255.

I included the ChrW(900) character because it illustrates how =
differently certain characters may be handled.

The second message box contains info about the two Unicode characters:

1 =CE=84 63 ? 900 =CE=84
2 =E2=80=98 145 =E2=80=98 8216 =E2=80=98

The six columns contain the following:
1) i (position within the string)
2) Mid(s, i, 1) the character at position i.
3) Asc(Mid(s, i, 1)) value of the character, sometimes and sometimes =
not.
4) Chr(Asc(Mid(s, i, 1))) Character associated with the reported Asc =
value.
5) AscW(Mid(s, i, 1)) Unicode value of the character.
6) ChrW(AscW(Mid(s, i, 1))) Character associated with the reported =
AscW value.

The Asc function almost always returns an 8-bit value, and AscW =
returns a 16-bit value. For certain Locales, Asc returns the same =
16-bit value as AscW. See the scripting help file for info on the =
GetLocale and SetLocale functions. The thing to note is that depending =
on Locale, for some Unicode characters, the Asc function returns returns =
63, a value that corresponds to a question mark, and for others it =
returns a value under 256 that displays the same character as is =
displayed by the Unicode character. So ChrW(900) maps to a question =
mark but ChrW(8216) maps to Chr(145). I don't have any examples that =
would produce the inverted question mark you talked about in your early =
posts.

Your posts talk about a number of code pages and charsets, like 65001 =
and utf-8 and iso-8859-1. I believe that charset 65001 represents all =
characters as fixed-length two-byte values, so it can handle all the =
thousands of standard Unicode characters. UTf-8 is a variable length =
encoding that uses one to four bytes to represent a character. It can =
handle all the characters that charset 65001 can handle. Charset =
iso-8859-1 can only handle 256 8-bit characters.

I think you should build a little standalone VBScript that displays =
many of your problematic characters in something like the six columns I =
did above, and post the result. Perhaps we can figure out a way to fix =
the problem after you show us what the problem is. It might help if you =
tell us your Locale number too. Control-C can be used to copy the text =
from a message box.

Option Explicit
Dim i, j, s, sMsg
s =3D "Hello *'" & ChrW(900) & "=E2=80=98* Unicode"
msgbox s & vbcrlf & sKeepOnlyUnicode(s)
s =3D sKeepOnlyUnicode(s)

For i =3D 1 To Len(s)
sMsg =3D sMsg & i & vbTab & Mid(s, i, 1) & vbTab & _
Asc(Mid(s, i, 1)) & vbTab & Chr(Asc(Mid(s, i, 1))) & vbTab & _
AscW(Mid(s, i, 1)) & vbTab & ChrW(AscW(Mid(s, i, 1))) & vbCrLf
Next 'i
MsgBox sMsg

Function sKeepOnlyUnicode(sAnyString)
'Returns sAnyString with only Unicode [actually, all
' characters outside the range ChrW(0) to
' ChrW(255)] being kept. VBScript strings are made
' up of 16-bit characters so they can handle a
' lot of Unicode stuff.
With New RegExp
.Global =3D True
.Pattern =3D "[\u0000-\u00FF]"
sKeepOnlyUnicode =3D .Replace(sAnyString, "")
End With
End Function 'sKeepOnlyUnicode(sAnyString)


-Paul Randall
"S N" <uandme72 [at] yahoo.com> wrote in message =
news:%23m$1focjIHA.748 [at] TK2MSFTNGP04.phx.gbl...
i changed the codepage tp 65001 and charset to utf-8, then the =
question mark ? showing earlier, has changed to the rectangle as shown =
below.
=E2=80=98
the database field also shows the same character stored in it.
please help.

"Anthony Jones" <Ant [at] yadayadayada.com> wrote in message =
news:ejiWc1tiIHA.5780 [at] TK2MSFTNGP06.phx.gbl...
My guess is that they are not " " but are =E2=80=98 =E2=80=9C =
=E2=80=9D typically cut'n'pasted in from Microsoft Word.

These are still in the Windows-1252 range of characters but are =
not strictly in the iso-8859-1 set.

Don't use http-equiv meta tags use real headers instead.

IOW ditch the meta tags and include this:-

<%Response.CharSet =3D "Windows-1252"%>

I'm not hopeful because you are probably using IE and IE will =
treat ISO-8859-1 as Windows-1252 anyway.

Always use Server.HtmlEncode on values retrieved from the =
Database. Stop mucking about with any other approach.

If that doesn't work view the html source from the browser. What =
is the server actually sending.

Another alternative is stop using Windows-1252.

Save your pages as UTF-8 change the codepage at the top of the =
page to 65001 and include Response.CharSet =3D "UTF-8" in your page.

BTW, Have you looked at the field content directly using the DB =
management tool?


--
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72 [at] yahoo.com> wrote in message =
news:OgWpL$piIHA.4344 [at] 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 =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">
<% [at] 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 [at] yadayadayada.com> wrote in message =
news:%23jGo1GRiIHA.5088 [at] TK2MSFTNGP02.phx.gbl...
> "Bob Barrows [MVP]" <reb01501 [at] NOyahoo.SPAMcom> wrote in =
message
> news:%233n2yuBiIHA.4744 [at] 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.
>>
>
> 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
>
>
------=_NextPart_000_0022_01C89825.DE08F500
Content-Type: text/html;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable

=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<META content=3D"MSHTML 6.00.2900.3157" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>i have checked the access database. =
when i open the
access table, there also i am finding the rectangular block =
whereever i
expect apostrophe .</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>also i have started using =
server.htmlencode for
retrieving values from the database. but it displays the new line =
characters and
paragraph characters (<BR> and <p> notations) stored in the =
text
field as such. meaning instead of using these characters as commands for =
new
line it is displaying them as it is, ie as "<BR>" and "<p>". =
in this
way the paragraph boundaries has gone.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>please help me with the above two
problems.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<BLOCKQUOTE dir=3Dltr
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Paul Randall" <<A
href=3D"mailto:paulr901 [at] cableone.net">paulr901 [at] cableone.net</A>> =
wrote in
message <A
=
href=3D"news:OOTWT7fjIHA.4320 [at] TK2MSFTNGP06.phx.gbl">news:OOT WT7fjIHA.4320=
[at] TK2MSFTNGP06.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for posting one of your =
problematic
characters.  I think one of the problems is that a number of =
distinct
concepts, such as charset, font, and locale, are being blurred =
together. 
At first you mentioned having problems with the single and double =
quote
characters, and defined them as apostrophe character ' and double =
quote
".  Recently you posted the =E2=80=98 character, which I assume =
is what you meant
by an apostrophe character.  It certainly looks a lot like what I =
would
call a single quote, but if you put my single quote ('), and your =
single quote
together, you can see that they are different: (=E2=80=98').  =
Well, maybe you can
see the difference, and maybe you can't.  It all depends on what =
font the
characters are being displayed in.  I think in general, if a font =
does
not contain a glyph for a character, then it displays a square or =
rectangular
box for that character.  I think most fonts contain glyphs for =
all
characters in the range Chr(32) to Chr(127).  Many fonts contain =
glyphs
for characters in the range Chr(128) to Chr(255) too.  Many fonts =
also
include glyphs for some characters in the range ChrW(256) to =
ChrW(65535),
which are Unicode characters.  My knowledge of Unicode is =
limited, so
some of my terminology may not be technically correct, and I would =
appreciate
being corrected.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Copy the code below into a .vbs file =
and run
it.  You will get two message boxes.  The first message box =
will
contain two lines:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Hello *'=CE=84=E2=80=98* =
Unicode</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>=CE=84=E2=80=98</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>The first line contains a mixture =
of what
might be considered Unicode and non-Unicode characters.  The =
three
characters between the asterisks (*) might all be considered single =
quotes,
but only the first one is Chr(39), the character I consider a single
quote.  The second one is ChrW(900), and the third one is your =
single
quote, ChrW(8216).</DIV>
<DIV> </DIV>
<DIV>The second line displays what is left of the first line after =
removing
all characters whose AscW value is less than 255.</DIV>
<DIV> </DIV>
<DIV>I included the ChrW(900) character because it illustrates how =
differently
certain characters may be handled.</DIV>
<DIV> </DIV>
<DIV>The second message box contains info about the two Unicode
characters:</DIV>
<DIV> </DIV>
<DIV>1 =CE=84 63 ? 900 =CE=84</DIV>
=
<DIV>2 =E2=80=98 145 =E2=80=98 8216 =E2=80=98</D=
IV>
<DIV> </DIV>
<DIV>The six columns contain the following:<BR>1) i (position within =
the
string)<BR>2) Mid(s, i, 1) the character at position i.<BR>3) =
Asc(Mid(s, i,
1)) value of the character, sometimes and sometimes not.<BR>4) =
Chr(Asc(Mid(s,
i, 1))) Character associated with the reported Asc value.<BR>5) =
AscW(Mid(s, i,
1)) Unicode value of the character.<BR>6) ChrW(AscW(Mid(s, i, 1))) =
Character
associated with the reported AscW value.</DIV>
<DIV> </DIV>
<DIV>The Asc function almost always returns an 8-bit value, and AscW =
returns a
16-bit value.  For certain Locales, Asc returns the same 16-bit =
value as
AscW.  See the scripting help file for info on the GetLocale and
SetLocale functions.  The thing to note is that depending on =
Locale, for
some Unicode characters, the Asc function returns returns 63, a value =
that
corresponds to a question mark, and for others it returns a value =
under 256
that displays the same character as is displayed by the Unicode
character.  So ChrW(900) maps to a question mark but ChrW(8216) =
maps to
Chr(145).  I don't have any examples that would produce the =
inverted
question mark you talked about in your early posts.</DIV>
<DIV> </DIV>
<DIV>Your posts talk about a number of code pages and charsets, like =
65001 and
utf-8 and iso-8859-1.  I believe that charset 65001 represents =
all
characters as fixed-length two-byte values, so it can handle all the =
thousands
of standard Unicode characters. UTf-8 is a variable length encoding =
that uses
one to four bytes to represent a character.  It can handle all =
the
characters that charset 65001 can handle.  Charset iso-8859-1 can =
only
handle 256 8-bit characters.</DIV>
<DIV> </DIV>
<DIV>I think you should build a little standalone VBScript that =
displays many
of your problematic characters in something like the six columns I did =
above,
and post the result.  Perhaps we can figure out a way to fix the =
problem
after you show us what the problem is.  It might help if you tell =
us your
Locale number too.  Control-C can be used to copy the text from a =
message
box.</DIV>
<DIV> </DIV>
<DIV>Option Explicit<BR>Dim i, j, s, sMsg<BR>s =3D "Hello *'" & =
ChrW(900)
& "=E2=80=98* Unicode"<BR>msgbox s & vbcrlf & =
sKeepOnlyUnicode(s)<BR>s =3D
sKeepOnlyUnicode(s)</DIV>
<DIV> </DIV>
<DIV>For i =3D 1 To Len(s)<BR> sMsg =3D sMsg & i & vbTab =
& Mid(s,
i, 1) & vbTab & _<BR>  Asc(Mid(s, i, 1)) & vbTab =
&
Chr(Asc(Mid(s, i, 1))) & vbTab & _<BR>  AscW(Mid(s, =
i, 1))
& vbTab & ChrW(AscW(Mid(s, i, 1))) &
vbCrLf<BR>Next 'i<BR>MsgBox sMsg</DIV>
<DIV> </DIV>
<DIV>Function sKeepOnlyUnicode(sAnyString)<BR>'Returns sAnyString with =
only
Unicode [actually, all<BR>' characters outside the range ChrW(0)
to<BR>' ChrW(255)] being kept.  VBScript strings are
made<BR>' up of 16-bit characters so they can handle =
a<BR>' lot of
Unicode stuff.<BR>With New RegExp<BR> .Global =3D =
True<BR> .Pattern =3D
"[\u0000-\u00FF]"<BR> sKeepOnlyUnicode =3D .Replace(sAnyString, =
"")<BR>End
With<BR>End Function 'sKeepOnlyUnicode(sAnyString)<BR>
<DIV> </DIV>
<DIV>-Paul Randall</DIV></FONT></DIV>
<BLOCKQUOTE dir=3Dltr
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"S N" <<A
href=3D"mailto:uandme72 [at] yahoo.com">uandme72 [at] yahoo.com</A>> wrote =
in message
<A
=
href=3D"news:%23m$1focjIHA.748 [at] TK2MSFTNGP04.phx.gbl">news:%2 3m$1focjIHA.7=
48 [at] TK2MSFTNGP04.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>i changed the codepage tp 65001 and =
charset to
utf-8, then the question mark ? showing earlier, has changed to the
rectangle as shown below.</FONT></DIV>
<DIV>=E2=80=98</DIV>
<DIV><FONT face=3DArial size=3D2>the database field also shows the =
same
character stored in it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>please help.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>"Anthony Jones" <<A
href=3D"mailto:Ant [at] yadayadayada.com">Ant [at] yadayadayada.com</A>> =
wrote in
message <A
=
href=3D"news:ejiWc1tiIHA.5780 [at] TK2MSFTNGP06.phx.gbl">news:eji Wc1tiIHA.5780=
[at] TK2MSFTNGP06.phx.gbl</A>...</DIV>
<BLOCKQUOTE dir=3Dltr
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT size=3D2>My guess is that they are not " " but are =
<SPAN
style=3D"FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; =
mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-GB; =
mso-fareast-language: EN-GB; mso-bidi-language: AR-SA">=E2=80=98
=E2=80=9C =E2=80=9D typically cut'n'pasted in from Microsoft =
Word.</SPAN></FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>These are still in the Windows-1252 range of =
characters
but are not strictly in the iso-8859-1 set.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Don't use http-equiv meta tags use real =
headers
instead.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>IOW ditch the meta tags and include =
this:-</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2><%Response.CharSet =3D =
"Windows-1252"%></FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I'm not hopeful because you are probably using =
IE and IE
will treat ISO-8859-1 as Windows-1252 anyway.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Always use Server.HtmlEncode on values =
retrieved from
the Database.  Stop mucking about with any other
approach.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>If that doesn't work view the html source from =
the
browser.  What is the server actually sending.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Another alternative is stop using
Windows-1252.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Save your pages as UTF-8 change the codepage =
at the top
of the page to 65001 and include Response.CharSet =3D "UTF-8" in =
your
page.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>BTW, Have you looked at the field content =
directly using
the DB management tool?</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2></FONT><FONT size=3D2></FONT><FONT =
size=3D2></FONT><FONT
size=3D2></FONT><FONT size=3D2></FONT><BR>-- <BR>Anthony Jones - =
MVP
ASP/ASP.NET</DIV>
<BLOCKQUOTE
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"S N" <<A
href=3D"mailto:uandme72 [at] yahoo.com">uandme72 [at] yahoo.com</A>> =
wrote in
message <A
=
href=3D"news:OgWpL$piIHA.4344 [at] TK2MSFTNGP03.phx.gbl">news:OgW pL$piIHA.4344=
[at] TK2MSFTNGP03.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>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 </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>DataPrep =3D =
Replace(DataPrep, """",
"&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
=
size=3D2><STRONG>response.write(server.htmlencode(myrs(3)))   =
'
where 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 page</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><STRONG><!DOCTYPE HTML =
PUBLIC
"-//W3C//DTD HTML 4.01 =
Transitional//EN"><BR><</STRONG></FONT><A
href=3D'mailto:% [at] LANGUAGE=3D"VBSCRIPT'><FONT face=3DArial
size=3D2><STRONG>% [at] LANGUAGE=3D"VBSCRIPT</STRONG></FONT></A><FONT =
face=3DArial
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
http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Diso-8859-1"
/><BR><meta http-equiv=3D"Content-Language" =
content=3D"en-us"
/></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
href=3D"mailto:Ant [at] yadayadayada.com"><FONT face=3DArial
size=3D2>Ant [at] yadayadayada.com</FONT></A><FONT face=3DArial =
size=3D2>> wrote
in message </FONT><A
href=3D"news:%23jGo1GRiIHA.5088 [at] TK2MSFTNGP02.phx.gbl"><FONT =
face=3DArial
=
size=3D2>news:%23jGo1GRiIHA.5088 [at] TK2MSFTNGP02.phx.gbl</FONT></A><FONT
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial =
size=3D2>> "Bob
Barrows [MVP]" <</FONT><A
href=3D"mailto:reb01501 [at] NOyahoo.SPAMcom"><FONT face=3DArial
size=3D2>reb01501 [at] NOyahoo.SPAMcom</FONT></A><FONT face=3DArial =
size=3D2>>
wrote in message<BR>> </FONT><A
href=3D"news:%233n2yuBiIHA.4744 [at] TK2MSFTNGP06.phx.gbl"><FONT =
face=3DArial
=
size=3D2>news:%233n2yuBiIHA.4744 [at] TK2MSFTNGP06.phx.gbl</FONT></A><FONT
face=3DArial size=3D2>...<BR>>> Daniel Crichton =
wrote:<BR>>>
> &apos; and &quot; are HTML entities - these are =
converted
by web<BR>>> > browsers into ' and " =
respectively.<BR>>>
><BR>>> > If you just want to print the literal =
characters,
that's easy enough:<BR>>> ><BR>>> > =
Response.Write
""""<BR>>> ><BR>>> > will print a single " =
(there are
4 " in that line, the two outer ones<BR>>> > are the =
string
containers, the two inners generate the single " as<BR>>> =
>
doubling them up inside a string turns them into a literal
instead).<BR>>> ><BR>>> > another =
example<BR>>>
><BR>>> > Response.Write "<a href=3D""</FONT><A
href=3D'http://myurl.com/apage.asp"">This'><FONT face=3DArial
size=3D2>http://myurl.com/apage.asp"">This</FONT></A><FONT =
face=3DArial
size=3D2> is a<BR>>> > link</a>"<BR>>> > =
Notice
how you just double up the quotation marks.<BR>>> =
><BR>>>
> For an apostrophe you don't need to do anything
special:<BR>>> ><BR>>> > Response.Write =
"They're not
here"<BR>>> ><BR>>> > So what problem are you =
having
with quotes and apostrophes?<BR>>> =
><BR>>><BR>>>
From the original post: "my code using response.write replaces " =

character<BR>>> with question<BR>>>
mark"<BR>>><BR>>> It's most likely a codepage =
problem. I've
been holding back from replying<BR>> to<BR>>> this =
because
Anthony typically has the most reliable advice for =
these<BR>>>
situations.<BR>>><BR>> <BR>> Thanks for the vote of
confidence Bob but it baffles me.  ;)<BR>> <BR>> =
Since " is
within the lower ascii range 0-127 the only encoding that =
could<BR>>
screw this up would be UTF-16.  But if the browser thought =
it was
getting<BR>> say Windows-1252 and yet the server was encoding =
to
UTF-16 (or vice versa)<BR>> the content would be completely
garbled.<BR>> <BR>> I suspect that what the OP thinks is =
happening
and what actually is are very<BR>> different.  Like Dan =
says I
think we would need to see some actual code to<BR>> make =
sense of
this.<BR>> <BR>> -- <BR>> Anthony Jones - MVP
ASP/ASP.NET<BR>> <BR>></FONT>
</BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0022_01C89825.DE08F500--
S N [ So, 06 April 2008 17:06 ] [ ID #1936561 ]

Re: printing character ' and " in asp using vbscript

>i have checked the access database. when i open the access table,
>there also i am finding the rectangular block whereever i expect apostrophe
..
>also i have started using server.htmlencode for retrieving values from the
>database. but it displays the new line characters and paragraph characters
>(<BR> and <p> notations) stored in the text field as such. meaning instead
of
>using these characters as commands for new line it is displaying them as
it is,
>ie as "<BR>" and "<p>". in this way the paragraph boundaries has gone.

If access is showing the wrong character that indicates the data is corrupt.

If the field contains HTML (which it appears it does if it has <br> and <p>
elements that you expect to be honors) then you should not be using
Server.HTMLEncode. It has to be assumed that a field containing HTML is
already HTML encoded.

This is a long thread, I can't remember if you indicated how the data
arrived in the DB in the first place.

--
Anthony Jones - MVP ASP/ASP.NET
Anthony Jones [ So, 06 April 2008 22:37 ] [ ID #1936564 ]

Re: printing character ' and " in asp using vbscript

i had copied the data from a word file and using control-c i had pasted it
into a richtext textbox in my asp form.

also please tell me how to ensure that regardless of whether the data is
html encoded or not, my server.htmlencode should work alright.


"Anthony Jones" <Ant [at] yadayadayada.com> wrote in message
news:expbSYCmIHA.1208 [at] TK2MSFTNGP05.phx.gbl...
> >i have checked the access database. when i open the access table,
>>there also i am finding the rectangular block whereever i expect
>>apostrophe
> .
>>also i have started using server.htmlencode for retrieving values from the
>>database. but it displays the new line characters and paragraph characters
>>(<BR> and <p> notations) stored in the text field as such. meaning instead
> of
>>using these characters as commands for new line it is displaying them as
> it is,
>>ie as "<BR>" and "<p>". in this way the paragraph boundaries has gone.
>
> If access is showing the wrong character that indicates the data is
> corrupt.
>
> If the field contains HTML (which it appears it does if it has <br> and
> <p>
> elements that you expect to be honors) then you should not be using
> Server.HTMLEncode. It has to be assumed that a field containing HTML is
> already HTML encoded.
>
> This is a long thread, I can't remember if you indicated how the data
> arrived in the DB in the first place.
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>
S N [ So, 06 April 2008 22:49 ] [ ID #1936565 ]

Re: printing character ' and " in asp using vbscript

"S N" <uandme72 [at] yahoo.com> wrote in message
news:%23YLk4eCmIHA.1188 [at] TK2MSFTNGP04.phx.gbl...

> "Anthony Jones" <Ant [at] yadayadayada.com> wrote in message
> news:expbSYCmIHA.1208 [at] TK2MSFTNGP05.phx.gbl...
>> >i have checked the access database. when i open the access table,
>>>there also i am finding the rectangular block whereever i expect
>>>apostrophe
>> .
>>>also i have started using server.htmlencode for retrieving values from
>>>the
>>>database. but it displays the new line characters and paragraph
>>>characters
>>>(<BR> and <p> notations) stored in the text field as such. meaning
>>>instead
>> of
>>>using these characters as commands for new line it is displaying them as
>> it is,
>>>ie as "<BR>" and "<p>". in this way the paragraph boundaries has gone.
>>
>> If access is showing the wrong character that indicates the data is
>> corrupt.
>>
>> If the field contains HTML (which it appears it does if it has <br> and
>> <p>
>> elements that you expect to be honors) then you should not be using
>> Server.HTMLEncode. It has to be assumed that a field containing HTML is
>> already HTML encoded.
>>
>> This is a long thread, I can't remember if you indicated how the data
>> arrived in the DB in the first place.
>>
>> --
>> Anthony Jones - MVP ASP/ASP.NET
>>
>>
>
>
>i had copied the data from a word file and using control-c i had pasted it
>into a richtext textbox in my asp form.
>
> also please tell me how to ensure that regardless of whether the data is
> html encoded or not, my server.htmlencode should work alright.
>
>

I haven't read the whole thread, but pasting directly from Word into a rich
text box is asking for trouble. I recommend pasting from Word into Notepad,
then taking the result and pasting it into the Rich text box. Word
sometimes does odd things with what should be "double quotes". And it
retains a whole load of Word-specific formatting - often over-riding your
carefully crafted css.

--
Mike Brind
Microsoft MVP - ASP/ASP.NET
Paxtonend [ Mo, 07 April 2008 08:56 ] [ ID #1937231 ]

Re: printing character ' and " in asp using vbscript

also please tell me how to ensure that regardless of whether the data is
html encoded or not, my server.htmlencode should work alright.








"Mike Brind [MVP]" <paxtonend [at] hotmail.com> wrote in message
news:OtkF6xHmIHA.1680 [at] TK2MSFTNGP06.phx.gbl...
>
> "S N" <uandme72 [at] yahoo.com> wrote in message
> news:%23YLk4eCmIHA.1188 [at] TK2MSFTNGP04.phx.gbl...
>
>> "Anthony Jones" <Ant [at] yadayadayada.com> wrote in message
>> news:expbSYCmIHA.1208 [at] TK2MSFTNGP05.phx.gbl...
>>> >i have checked the access database. when i open the access table,
>>>>there also i am finding the rectangular block whereever i expect
>>>>apostrophe
>>> .
>>>>also i have started using server.htmlencode for retrieving values from
>>>>the
>>>>database. but it displays the new line characters and paragraph
>>>>characters
>>>>(<BR> and <p> notations) stored in the text field as such. meaning
>>>>instead
>>> of
>>>>using these characters as commands for new line it is displaying them
>>>>as
>>> it is,
>>>>ie as "<BR>" and "<p>". in this way the paragraph boundaries has gone.
>>>
>>> If access is showing the wrong character that indicates the data is
>>> corrupt.
>>>
>>> If the field contains HTML (which it appears it does if it has <br> and
>>> <p>
>>> elements that you expect to be honors) then you should not be using
>>> Server.HTMLEncode. It has to be assumed that a field containing HTML is
>>> already HTML encoded.
>>>
>>> This is a long thread, I can't remember if you indicated how the data
>>> arrived in the DB in the first place.
>>>
>>> --
>>> Anthony Jones - MVP ASP/ASP.NET
>>>
>>>
>>
>>
>>i had copied the data from a word file and using control-c i had pasted it
>>into a richtext textbox in my asp form.
>>
>> also please tell me how to ensure that regardless of whether the data is
>> html encoded or not, my server.htmlencode should work alright.
>>
>>
>
> I haven't read the whole thread, but pasting directly from Word into a
> rich text box is asking for trouble. I recommend pasting from Word into
> Notepad, then taking the result and pasting it into the Rich text box.
> Word sometimes does odd things with what should be "double quotes". And
> it retains a whole load of Word-specific formatting - often over-riding
> your carefully crafted css.
>
> --
> Mike Brind
> Microsoft MVP - ASP/ASP.NET
>
S N [ Mo, 07 April 2008 18:54 ] [ ID #1937233 ]

Re: printing character ' and " in asp using vbscript

Gazing into my crystal ball I observed "S N" <uandme72 [at] yahoo.com>
writing in news:#YLk4eCmIHA.1188 [at] TK2MSFTNGP04.phx.gbl:

>
>
> "Anthony Jones" <Ant [at] yadayadayada.com> wrote in message
> news:expbSYCmIHA.1208 [at] TK2MSFTNGP05.phx.gbl...
>> >i have checked the access database. when i open the access table,
>>>there also i am finding the rectangular block whereever i expect
>>>apostrophe
>> .
>>>also i have started using server.htmlencode for retrieving values
>>>from the database. but it displays the new line characters and
>>>paragraph characters (<BR> and <p> notations) stored in the text
>>>field as such. meaning instead
>> of
>>>using these characters as commands for new line it is displaying
>>>them as
>> it is,
>>>ie as "<BR>" and "<p>". in this way the paragraph boundaries has
>>>gone.
>>
>> If access is showing the wrong character that indicates the data is
>> corrupt.
>>
>> If the field contains HTML (which it appears it does if it has <br>
>> and <p>
>> elements that you expect to be honors) then you should not be using
>> Server.HTMLEncode. It has to be assumed that a field containing HTML
>> is already HTML encoded.
>>
>> This is a long thread, I can't remember if you indicated how the data
>> arrived in the DB in the first place.
>>
> i had copied the data from a word file and using control-c i had
> pasted it into a richtext textbox in my asp form.
>
> also please tell me how to ensure that regardless of whether the data
> is html encoded or not, my server.htmlencode should work alright.

I would suggest using a client side script to ensure the data pasted
from Word is going in correctly. Word is notorious for really bad,
bloated markup. Google for WYSIWYG textarea - I like the one from The
Man in Blue at [http://www.themaninblue.com/experiment/widgEditor/].

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Adrienne Boswell [ Mo, 07 April 2008 19:15 ] [ ID #1937234 ]

Re: printing character ' and " in asp using vbscript

"S N" <uandme72 [at] yahoo.com> wrote in message
news:u1pVKANmIHA.3940 [at] TK2MSFTNGP05.phx.gbl...

> "Mike Brind [MVP]" <paxtonend [at] hotmail.com> wrote in message
> news:OtkF6xHmIHA.1680 [at] TK2MSFTNGP06.phx.gbl...
>>
>> "S N" <uandme72 [at] yahoo.com> wrote in message
>> news:%23YLk4eCmIHA.1188 [at] TK2MSFTNGP04.phx.gbl...
>>
>>> "Anthony Jones" <Ant [at] yadayadayada.com> wrote in message
>>> news:expbSYCmIHA.1208 [at] TK2MSFTNGP05.phx.gbl...
>>>> >i have checked the access database. when i open the access table,
>>>>>there also i am finding the rectangular block whereever i expect
>>>>>apostrophe
>>>> .
>>>>>also i have started using server.htmlencode for retrieving values from
>>>>>the
>>>>>database. but it displays the new line characters and paragraph
>>>>>characters
>>>>>(<BR> and <p> notations) stored in the text field as such. meaning
>>>>>instead
>>>> of
>>>>>using these characters as commands for new line it is displaying them
>>>>>as
>>>> it is,
>>>>>ie as "<BR>" and "<p>". in this way the paragraph boundaries has gone.
>>>>
>>>> If access is showing the wrong character that indicates the data is
>>>> corrupt.
>>>>
>>>> If the field contains HTML (which it appears it does if it has <br> and
>>>> <p>
>>>> elements that you expect to be honors) then you should not be using
>>>> Server.HTMLEncode. It has to be assumed that a field containing HTML
>>>> is
>>>> already HTML encoded.
>>>>
>>>> This is a long thread, I can't remember if you indicated how the data
>>>> arrived in the DB in the first place.
>>>>
>>>> --
>>>> Anthony Jones - MVP ASP/ASP.NET
>>>>
>>>>
>>>
>>>
>>>i had copied the data from a word file and using control-c i had pasted
>>>it into a richtext textbox in my asp form.
>>>
>>> also please tell me how to ensure that regardless of whether the data is
>>> html encoded or not, my server.htmlencode should work alright.
>>>
>>>
>>
>> I haven't read the whole thread, but pasting directly from Word into a
>> rich text box is asking for trouble. I recommend pasting from Word into
>> Notepad, then taking the result and pasting it into the Rich text box.
>> Word sometimes does odd things with what should be "double quotes". And
>> it retains a whole load of Word-specific formatting - often over-riding
>> your carefully crafted css.
>>
>> --
>> Mike Brind
>> Microsoft MVP - ASP/ASP.NET
>>
>
>
> also please tell me how to ensure that regardless of whether the data is
> html encoded or not, my server.htmlencode should work alright.

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
Paxtonend [ Mo, 07 April 2008 21:27 ] [ ID #1937236 ]

Re: printing character ' and " in asp using vbscript

This is a multi-part message in MIME format.

------=_NextPart_000_002D_01C89BFB.9E887A20
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

you have guessed it very correctly that i am entering html code into the =
database (like table tags <td> <tr> in 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).

please help.



> 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
>
>
>
------=_NextPart_000_002D_01C89BFB.9E887A20
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.3314" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>you have guessed it very correctly that =
i am
entering html code into the database (like table tags <td> =
<tr> in
particular) with the <BR> idea that this takes effect when it
is pulled back to a web page, and hence i dont want to
server.htmlencode it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>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).</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>> As Anthony said, if you are =
entering html code
into the database with the <BR>> idea that this takes effect when you =
pull it
back to a web page, you do not <BR>> want to server.htmlencode =
it. 
Since you are using a Rich Text Editor, I am <BR>> assuming that this =
will
apply html tags to the text on entry, and you want <BR>> them to act =
on the
output.<BR>> <BR>> What you really want to do is to make sure no
javascript or clientside <BR>> vbscript gets injected.  =
<STRONG><FONT
color=3D#ff0000>One way to do this is just to reject any input that =
<BR>>
contains the string "<script>" in it during your server-side
validation.<BR></FONT></STRONG>> <BR>> --<BR>> Mike =
Brind<BR>>
Microsoft MVP - ASP/ASP.NET <BR>> <BR>>
<BR>></FONT></DIV></BODY></HTML>

------=_NextPart_000_002D_01C89BFB.9E887A20--
S N [ Fr, 11 April 2008 14:13 ] [ ID #1940424 ]

Re: printing character ' and " in asp using vbscript

"S N" <uandme72 [at] yahoo.com> wrote in message
news:OI%23$718mIHA.2304 [at] 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> > <tr> in 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
Paxtonend [ Fr, 11 April 2008 22:10 ] [ ID #1940433 ]
Webserver » microsoft.public.inetserver.asp.general » Re: printing character ' and " in asp using vbscript

Vorheriges Thema: Invalid class string
Nächstes Thema: HELP: managing multiple virtual folders of cloned websites