469,270 Members | 1,093 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Remove ASCII 1 to 31 from input string

Hi All,

I have a simple ASP page with a text box and a submit button which displays the text box value on the page when it is submitted after removing all special characters. It works fine in normal cases but fails when the user types the key combination Alt+1 (☺) to Alt+31(▼). For ex: It converts Alt+1 to 9786. I am not sure what is the reason and how to fix this. Please help!

The ASP code:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <%
  3. Dim sData
  4. Dim ReplacedString
  5.  
  6. sData = request("ASCIIData")
  7.  
  8. Set RegularExpressionObject = New RegExp
  9.  
  10. With RegularExpressionObject
  11.     .Pattern = "[^A-Za-z0-9]"
  12.     .IgnoreCase = True
  13.     .Global = True
  14. End With
  15.  
  16. ReplacedString = RegularExpressionObject.Replace(sData, " ")
  17.  
  18. Response.Write "Replaced " & sData & " with " & ReplacedString
  19.  
  20. Set RegularExpressionObject = nothing
  21.  
  22. %>
  23.  
  24. <form id="f1" name="f1" method="post" action="ASCII.asp">
  25.     <input name="ASCIIData"/>
  26.     <input type="submit" value="submit"/>
  27. </FORM>
  28. </html>
Apr 29 '08 #1
1 2343
jeffstl
432 Expert 256MB
Off hand I'm not familiar with the regular expression object

but...why not just...

Expand|Select|Wrap|Line Numbers
  1.  
  2. if cstr(ConvertedValue) = "9786" then
  3.      ConvertedValue = DesiredValue
  4. end if
  5.  
  6.  
Jun 20 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Randell D. | last post: by
5 posts views Thread by sathyashrayan | last post: by
3 posts views Thread by TJO | last post: by
6 posts views Thread by Jeff | last post: by
19 posts views Thread by Thomas W | last post: by
10 posts views Thread by Mike Schilling | last post: by
9 posts views Thread by Smiley | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.