Soren Winslow
String Converter
This script is one of those fun, but almost useless scripts, It converts any string inputed into an ASCII code string, Hexadecimal code string, Octal code string, Binary code string, Server.URLEncode string, and Server.HTMLEncode string.


Here is the ASP code for this script:

 <form name="ConvStr" method="post" action="<%=Request.ServerVariables("URL")%>">
 <input type="text" name="TheStr" value="<%=Request.Form("TheStr")%>" size="75" class="bnotes">
 <input type="submit" name="DoConv" value="Convert" class="bnotes">
 </form>

<%
If Len(Request.Form("TheStr")) <> 0 Then

  TheStr = Request.Form("TheStr")

  ASCIIStr = ""
  Hexstr = ""
  OctStr = ""
  BinStr = ""

  For x = 1 to Len(TheStr)
      'Get ASCII Number
      TheChr = Asc(Mid(TheStr,x,1))
      IF Len(TheChr) < 3 Then
        Do Until Len(TheChr) = 3
           TheChr = "0" & TheChr
        Loop
      End IF
      ASCIIStr = ASCIIStr & TheChr & " "

      'Get Hexadecimal number
      HexVal = Hex(TheChr)
      IF Len(HexVal) < 2 Then
        Do Until Len(HexVal) = 2
           HexVal = "0" & HexVal
        Loop
      End IF
      HexStr = HexStr & HexVal & " "
      HexVal = ""

      'Get Octal Number
      OctVal = Oct(TheChr)
      IF Len(OctVal) < 3 Then
        Do Until Len(OctVal) = 3
           OctVal = "0" & CStr(OctVal)
        Loop
      End IF
      OctStr = OctStr & OctVal & " "
      OctVal = ""

      'Get Binary Number
      Do Until CInt(TheChr) = 0
        TempValue = TheChr Mod 2
        BinValue = CStr(TempValue) & BinValue
        TheChr = TheChr \ 2
      Loop
      IF Len(BinValue) < 8 Then
        Do Until Len(BinValue) = 8
           BinValue = "0" & BinValue
        Loop
      End IF
      BinStr = BinStr & " " & BinValue
      BinValue = ""
  Next

  Response.Write "<hr>"

  Response.Write "<div style=" & chr(34) & "padding:5px;" & chr(34) & "><b>" & _
                      Server.HTMLEncode(TheStr) & _
                 "</b></div>"

  Response.Write "<div style=" & chr(34) & "padding:5px;" & chr(34) & "><b>ASCII</b>: " & _
                       "<div style=" & chr(34) & "padding:3px;padding-left:20px;" & chr(34) & ">" & _
                       ASCIIStr & _
                       "</div>" & _
                 "</div>"

  Response.Write "<div style=" & chr(34) & "padding:5px;" & chr(34) & "><b>Hexidecimal</b>: " & _
                       "<div style=" & chr(34) & "padding:3px;padding-left:20px;" & chr(34) & ">" & _
                       HexStr & _
                       "</div>" & _
                 "</div>"

  Response.Write "<div style=" & chr(34) & "padding:5px;" & chr(34) & "><b>Octal</b>: " & _
                       "<div style=" & chr(34) & "padding:3px;padding-left:20px;" & chr(34) & ">" & _
                       OctStr & _
                       "</div>" & _
                 "</div>"

  Response.Write "<div style=" & chr(34) & "padding:5px;" & chr(34) & "><b>Binary</b>: " & _
                       "<div style=" & chr(34) & "padding:3px;padding-left:20px;" & chr(34) & ">" & _
                       BinStr & _
                       "</div>" & _
                 "</div>"

  Response.Write "<div style=" & chr(34) & "padding:5px;" & chr(34) & "><b>URLEncode</b>: " & _
                       "<div style=" & chr(34) & "padding:3px;padding-left:20px;" & chr(34) & ">" & _
                       Server.URLEncode(TheStr) & _
                       "</div>" & _
                 "</div>"

  Response.Write "<div style=" & chr(34) & "padding:5px;" & chr(34) & "><b>HTMLEncode</b>: " & _
                       "<div style=" & chr(34) & "padding:3px;padding-left:20px;" & chr(34) & ">" & _
                       Server.HTMLEncode(Server.HTMLEncode(TheStr)) & _
                       "</div>" & _
                 "</div>"

End If

%>

               
© 1967 - 2008 Soren Winslow