Link to home
Start Free TrialLog in
Avatar of Andrew
AndrewFlag for United States of America

asked on

ASP character encoding?

Hello, can someone explain to me why and how to keep one of my .asp pages from passing
this character é as this é from one .asp page to the next and also into my SQL DB via a SQL Insert Query?

IE9: ʎ = ̩
Chrome18: ʎ = ̩
FireFox9:  é = é
 
asp1.asp=

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- #include file="ASPConnection.inc" -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<form id="DonateForm" name="DonateForm" action="GCP21Reg2.asp" class="formular" method="post">
Name*</label><input id="txtFName" class="validate[required] text-input" name="txtFName" size="35" type="text" value="" />
</form>

asp2.asp=

sFirstName = Request("txtFName")
response.write sFirstName


TIA,
Andrew
Avatar of rlively
rlively
Flag of United States of America image

On asp2.asp, clean the string before assigning to the sFirstName variable.

sFirstName = CleanTheString(Request("txtFName")

Then whenever you reference sFirstName (to response.write to the page or to use in a sql query), it will contain only the alphanumeric characters.

There are many ways to do that - I just included the method from here http://www.visualbasicscript.com/Remove-all-non-AlphaNumeric-characters-from-String-m26939.aspx:

  Function CleanTheString(theString)
      strAlphaNumeric = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 'Used to check for numeric characters.
      For i = 1 to len(theString)
          strChar = mid(theString,i,1)
          If instr(strAlphaNumeric,strChar) Then
              CleanedString = CleanedString & strChar
          End If
      Next
      CleanTheString = CleanedString
  End Function
Avatar of Andrew

ASKER

Thanks for the reply, but this is an international registration form and names such as Pérez-Quintero need to be written to the SQL db and displayed in browsers as such.
Then why do you need to convet chars at all?
And what's with the
<!--<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />

Open in new window

Why the <!-- ?
ASKER CERTIFIED SOLUTION
Avatar of tobzzz
tobzzz
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial