Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spaces show as ? marks? 2

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
I've never had this happen before, I have a text area field that people put in their stuff, sends to the database which is Access - shows in the database as a regular space (not  ).

Pull it out of the database and it displays any spaces as ?

Any idea?

"Ever stop to think, and forget to start again?"

Stuart
A+, Net+, Security+
 
Maybe write a little routine that shows the ASCII value of these mystery characters.
 
server.htmlencode gets rid of the ? but promptly looses any CRLF's that may be in the field. And server.htmlencode will then display any <BR> as <BR>

"Ever stop to think, and forget to start again?"

Stuart
A+, Net+, Security+
 
maybe thats where I'm going awry.

I've got this

Code:
strText3=replace(request("txtDescription"),"'","''")
strText3=replace(strText3,vbCRLF,chr(13) & chr(10))





"Ever stop to think, and forget to start again?"

Stuart
A+, Net+, Security+
 
Got it,

I think Sheco was on the right track, and why I didn't think of it I do not know. Something was being returned in the field as it would display a space fine in the textarea - but if you went to every space and redid it, it then acted like a space - where before it would take the properties of almost like a string.

DNG's responses were - well not right. HTMLEncode would have been a quick fix, but not retaining formatting and not solving the problem to begin with. I still would have needed to go through each problem record and fix it like I am anyway.

However, DNG's followup suggestion - THAT was the mental jog to do it right, I format the text going into the database, and back out again if it goes to a text area again.

The origional problem of the ? showing inplace of spaces still remains, I've fixed it from continuing to happen, and if I have time I'll pursue Sheco's idea.

"Ever stop to think, and forget to start again?"

Stuart
A+, Net+, Security+
 
One you figure out which character code or codes is inserted instead of a space... it might be easy to write an UPDATE statement to fix it all.
 
Agreed. The problem you have is that your somehow getting undisplayable characters back. When you raw write those characters the browser does the only thing it can do, displays a question mark in lieu of trying to print an unprintable character. The worst part is that you likely will not see these characters if you view source (or they will show up as something else) because they are non-printable characters.

As Sheco said, use one entry as a test and try to get the ASCII code for the missing character. Once you have this code you should be able to do a simple replace to kill any occurrences of that code in your output. A better solution would be to figure out how those values are getting in there in the first place.

One option would be to setup a regular expression to match any characters in the ascii 1-32 range. You may want to exclude tab and the carriage return characters (or not, shouldn't make a difference). You don't weant 0 because thats an EOS, although if one of those snuck in then some nasty things will happen with your output (the Response buffer does some interesting things when you start shoving EOS's into it).

Reg Exp example:
Code:
<%
Option Explicit

'make a test string
Dim myString, ctr
Randomize
For ctr = 0 to 300
	myString = myString & Chr(Fix(Rnd()*255) + 1)
Next

Dim regex, chars(32)
Set regex = New RegExp
regex.Global = True
regex.Pattern = "[\0-\32]"

Response.Write "Original String:<textarea style=""width: 100%"">" & myString & "</textarea>"

Dim matches, match
Set matches = regex.Execute(myString)
For Each match in matches
	chars(Asc(match)) = chars(Asc(match)) + 1
Next

For ctr = 0 to 32
	If chars(ctr) > 0 Then Response.Write "<b>Chr(" & ctr & ")</b> - " & chars(ctr) & " occurrences<br>"
Next
%>

You could easily take portions of that out and run it against one of the offending strings from your database. You could also alter it and use the Replace() function from the RegExp object to replace everything in the 0-32 range for cleaner output.

barcode_1.gif
 
Hmm, good point. Last time I ran into this issue I was forcing ASCII which is probably why I didn't consider other character sets.

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top