Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: printing character ' and " in asp using vbscript
i am sorry, but the character showing as rectangle in my pc during composing
 of the message to this group, is now showing as  ' in the message finally a
ppearing on the server.
please help
"S N" <uandme72@yahoo.com> wrote in message news:%23m$1focjIHA.748@TK2MSFTNG
P04.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.
'
the database field also shows the same character stored in it.
please help.

"Anthony Jones" <Ant@yadayadayada.com> wrote in message news:ejiWc1tiIHA.578
0@TK2MSFTNGP06.phx.gbl...
My guess is that they are not " " but are ' " " typically cut'n'pasted in fr
om 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 = "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 mu
cking about with any other approach.

If that doesn't work view the html source from the browser.  What is the ser
ver 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 = "UTF-8" in your page.

BTW, Have you looked at the field content directly using the DB management t
ool?


-- 
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72@yahoo.com> wrote in message news:OgWpL$piIHA.4344@TK2MSFTNGP
03.phx.gbl...
i am attaching the sample code. actually i am printing from a field in acces
s database. the text entered in the database contains single quotes and doub
le 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@yadayadayada.com> wrote in message news:%23jGo1GRiIHA.5088@TK2MSFTNGP0
2.phx.gbl...
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%233n2yuBiIHA.4744@TK2MSFTNGP06.phx.gbl... 
> to 
> 
> 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 ve
ry
> 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
> 
>

Report this thread to moderator Post Follow-up to this message
Old Post
S N
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
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 e
lse 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.



Report this thread to moderator Post Follow-up to this message
Old Post
Jon Paal [MSMD]
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
which group should i consult. please help

"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message
news:13ufof3gdvavcd3@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.
>



Report this thread to moderator Post Follow-up to this message
Old Post
S N
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
I would start here:

microsoft.public.scripting.vbscript



Report this thread to moderator Post Follow-up to this message
Old Post
Jon Paal [MSMD]
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
You need to make sure response.charset and response.codepage are consistent 
otherwise you will get mess.

Its clear that you problem is with the data in the DB.

-- 
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72@yahoo.com> wrote in message news:O3b5VocjIHA.748@TK2MSFTNGP0
4.phx.gbl...
you have guessed it right, i am copying the text from ms word but am cleanin
g wordhtml using wordcleaner 3. 
further, i checked using 
Response.CharSet = "UTF-8" 
in this case the ? characters appears on every newline including the places 
where it was appearing earlier.

when i use
<%Response.CharSet = "Windows-1252"%>

still the problem of question marks remain. but it appears only as was appea
ring earlier (in place of " and not on every new line)
i checked the view source- the server is sending ? character itself to the b
rowser.
when i checked the database field, it is showing in invalid character in the
 shape of a rectangle stored where i want the  double quote " printed.

please help.
"Anthony Jones" <Ant@yadayadayada.com> wrote in message news:ejiWc1tiIHA.578
0@TK2MSFTNGP06.phx.gbl...
My guess is that they are not " " but are ' " " typically cut'n'pasted in fr
om 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 = "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 mu
cking about with any other approach.

If that doesn't work view the html source from the browser.  What is the ser
ver 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 = "UTF-8" in your page.

BTW, Have you looked at the field content directly using the DB management t
ool?


-- 
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72@yahoo.com> wrote in message news:OgWpL$piIHA.4344@TK2MSFTNGP
03.phx.gbl...
i am attaching the sample code. actually i am printing from a field in acces
s database. the text entered in the database contains single quotes and doub
le 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@yadayadayada.com> wrote in message news:%23jGo1GRiIHA.5088@TK2MSFTNGP0
2.phx.gbl...
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%233n2yuBiIHA.4744@TK2MSFTNGP06.phx.gbl... 
> to 
> 
> 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 ve
ry
> 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
> 
>

Report this thread to moderator Post Follow-up to this message
Old Post
Anthony Jones
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
All I'm seeing is a standard apostrophe.

If what you see in the DB is not the character you are expecting then your p
roblem is probably now with the languages you have installed.  I don't think
 all glyphs are installed for each font by default, you need to install the 
appropriate language for the system to be able to render them.

How is did the data arrive in the DB?  Via HTML Form and ASP?




-- 
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72@yahoo.com> wrote in message news:%23m$1focjIHA.748@TK2MSFTNG
P04.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.
'
the database field also shows the same character stored in it.
please help.

"Anthony Jones" <Ant@yadayadayada.com> wrote in message news:ejiWc1tiIHA.578
0@TK2MSFTNGP06.phx.gbl...
My guess is that they are not " " but are ' " " typically cut'n'pasted in fr
om 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 = "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 mu
cking about with any other approach.

If that doesn't work view the html source from the browser.  What is the ser
ver 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 = "UTF-8" in your page.

BTW, Have you looked at the field content directly using the DB management t
ool?


-- 
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72@yahoo.com> wrote in message news:OgWpL$piIHA.4344@TK2MSFTNGP
03.phx.gbl...
i am attaching the sample code. actually i am printing from a field in acces
s database. the text entered in the database contains single quotes and doub
le 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@yadayadayada.com> wrote in message news:%23jGo1GRiIHA.5088@TK2MSFTNGP0
2.phx.gbl...
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%233n2yuBiIHA.4744@TK2MSFTNGP06.phx.gbl... 
> to 
> 
> 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 ve
ry
> 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
> 
>

Report this thread to moderator Post Follow-up to this message
Old Post
Anthony Jones
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
"S N" <uandme72@yahoo.com> wrote in message
news:uCtqModjIHA.4196@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




Report this thread to moderator Post Follow-up to this message
Old Post
Anthony Jones
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
Thanks for posting one of your problematic characters.  I think one of the p
roblems is that a number of distinct concepts, such as charset, font, and lo
cale, are being blurred together.  At first you mentioned having problems wi
th the single and double quote characters, and defined them as apostrophe ch
aracter ' and double quote ".  Recently you posted the ‘ 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: (
').  Well, maybe you can see the difference, and maybe you can't.  It all d
epends on what font the characters are being displayed in.  I think in gener
al, if a font does not contain a glyph for a character, then it displays a s
quare or rectangular box for that character.  I think most fonts contain gly
phs 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 al
so 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 bei
ng corrected.

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

Hello *'΄‘* Unicode
΄‘

The first line contains a mixture of what might be considered Unicode and no
n-Unicode characters.  The three characters between the asterisks (*) might 
all be considered single quotes, but only the first one is Chr(39), the char
acter 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 c
haracters whose AscW value is less than 255.

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

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

1 ΄ 63 ? 900 ΄
2 ‘ 145 ‘ 8216 ‘

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 valu
e.

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 functi
ons.  The thing to note is that depending on Locale, for some Unicode charac
ters, the Asc function returns returns 63, a value that corresponds to a que
stion mark, and for others it returns a value under 256 that displays the sa
me 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 earl
y posts.

Your posts talk about a number of code pages and charsets, like 65001 and ut
f-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 stand
ard 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 cha
racters.

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, a
nd post the result.  Perhaps we can figure out a way to fix the problem afte
r 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 = "Hello *'" & ChrW(900) & "‘* Unicode"
msgbox s & vbcrlf & sKeepOnlyUnicode(s)
s = sKeepOnlyUnicode(s)

For i = 1 To Len(s)
sMsg = 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 = True
.Pattern = "[\u0000-\u00FF]"
sKeepOnlyUnicode = .Replace(sAnyString, "")
End With
End Function 'sKeepOnlyUnicode(sAnyString)


-Paul Randall
"S N" <uandme72@yahoo.com> wrote in message news:%23m$1focjIHA.748@TK2MSFTNG
P04.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.
‘
the database field also shows the same character stored in it.
please help.

"Anthony Jones" <Ant@yadayadayada.com> wrote in message news:ejiWc1tiIHA.578
0@TK2MSFTNGP06.phx.gbl...
My guess is that they are not " " but are ‘ “ ” 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 = "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 mu
cking about with any other approach.

If that doesn't work view the html source from the browser.  What is the ser
ver 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 = "UTF-8" in your page.

BTW, Have you looked at the field content directly using the DB management t
ool?


-- 
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72@yahoo.com> wrote in message news:OgWpL$piIHA.4344@TK2MSFTNGP
03.phx.gbl...
i am attaching the sample code. actually i am printing from a field in acces
s database. the text entered in the database contains single quotes and doub
le 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@yadayadayada.com> wrote in message news:%23jGo1GRiIHA.5088@TK2MSFTNGP0
2.phx.gbl...
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%233n2yuBiIHA.4744@TK2MSFTNGP06.phx.gbl... 
> to 
> 
> 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 ve
ry
> 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
> 
>

Report this thread to moderator Post Follow-up to this message
Old Post
Paul Randall
03-24-08 11:56 PM


Re: printing character ' and " in asp using vbscript
From your posts, I'd say that wordcleaner isn't doing what you expect -
every quote you've posted as a paste from your text is a curly open quote
which is what I'd expect a copy and paste direct from Word to include.

Dan

S wrote  on Mon, 24 Mar 2008 21:40:13 +0530:

> you have guessed it right, i am copying the text from ms word but am
> cleaning wordhtml using wordcleaner 3.
> further, i checked using
> Response.CharSet = "UTF-8"
> in this case the ? characters appears on every newline including the
> places where it was appearing earlier.

> when i use <%Response.CharSet = "Windows-1252"%>

> still the problem of question marks remain. but it appears only as was
> appearing earlier (in place of " and not on every new line)
> i checked the view source- the server is sending ? character itself to
> the browser.
> when i checked the database field, it is showing in invalid character
> in the shape of a rectangle stored where i want the  double quote "
> printed.

> please help.
>   "Anthony Jones" <Ant@yadayadayada.com> wrote in message
> news:ejiWc1tiIHA.5780@TK2MSFTNGP06.phx.gbl...
>   My guess is that they are not " " but are ' " " 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 = "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 = "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@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

>     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@yadayadayada.com> wrote in message
> news:%23jGo1GRiIHA.5088@TK2MSFTNGP02.phx.gbl... 
 
 
 
 
 
 
 
 

 
 

 
 
 
 



Report this thread to moderator Post Follow-up to this message
Old Post
Daniel Crichton
03-27-08 12:57 PM


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 d
atabase. 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@cableone.net> wrote in message news:OOTWT7fjIHA.432
0@TK2MSFTNGP06.phx.gbl...
Thanks for posting one of your problematic characters.  I think one of the p
roblems is that a number of distinct concepts, such as charset, font, and lo
cale, are being blurred together.  At first you mentioned having problems wi
th the single and double quote characters, and defined them as apostrophe ch
aracter ' and double quote ".  Recently you posted the ‘ 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: (
').  Well, maybe you can see the difference, and maybe you can't.  It all d
epends on what font the characters are being displayed in.  I think in gener
al, if a font does not contain a glyph for a character, then it displays a s
quare or rectangular box for that character.  I think most fonts contain gly
phs 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 al
so 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 bei
ng corrected.

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

Hello *'΄‘* Unicode
΄‘

The first line contains a mixture of what might be considered Unicode and no
n-Unicode characters.  The three characters between the asterisks (*) might 
all be considered single quotes, but only the first one is Chr(39), the char
acter 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 c
haracters whose AscW value is less than 255.

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

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

1 ΄ 63 ? 900 ΄
2 ‘ 145 ‘ 8216 ‘

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 valu
e.

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 functi
ons.  The thing to note is that depending on Locale, for some Unicode charac
ters, the Asc function returns returns 63, a value that corresponds to a que
stion mark, and for others it returns a value under 256 that displays the sa
me 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 earl
y posts.

Your posts talk about a number of code pages and charsets, like 65001 and ut
f-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 stand
ard 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 cha
racters.

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, a
nd post the result.  Perhaps we can figure out a way to fix the problem afte
r 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 = "Hello *'" & ChrW(900) & "‘* Unicode"
msgbox s & vbcrlf & sKeepOnlyUnicode(s)
s = sKeepOnlyUnicode(s)

For i = 1 To Len(s)
sMsg = 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 = True
.Pattern = "[\u0000-\u00FF]"
sKeepOnlyUnicode = .Replace(sAnyString, "")
End With
End Function 'sKeepOnlyUnicode(sAnyString)


-Paul Randall
"S N" <uandme72@yahoo.com> wrote in message news:%23m$1focjIHA.748@TK2MSFTNG
P04.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.
‘
the database field also shows the same character stored in it.
please help.

"Anthony Jones" <Ant@yadayadayada.com> wrote in message news:ejiWc1tiIHA.578
0@TK2MSFTNGP06.phx.gbl...
My guess is that they are not " " but are ‘ “ ” 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 = "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 mu
cking about with any other approach.

If that doesn't work view the html source from the browser.  What is the ser
ver 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 = "UTF-8" in your page.

BTW, Have you looked at the field content directly using the DB management t
ool?


-- 
Anthony Jones - MVP ASP/ASP.NET
"S N" <uandme72@yahoo.com> wrote in message news:OgWpL$piIHA.4344@TK2MSFTNGP
03.phx.gbl...
i am attaching the sample code. actually i am printing from a field in acces
s database. the text entered in the database contains single quotes and doub
le 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@yadayadayada.com> wrote in message news:%23jGo1GRiIHA.5088@TK2MSFTNGP0
2.phx.gbl...
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%233n2yuBiIHA.4744@TK2MSFTNGP06.phx.gbl... 
> to 
> 
> 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 ve
ry
> 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
> 
>

Report this thread to moderator Post Follow-up to this message
Old Post
S N
04-06-08 11:58 PM


Sponsored Links




Last Thread Next Thread Next
Pages (4): « 1 2 [3] 4 »
Search this forum -> 
Post New Thread

ASP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 12:12 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.