Link to home
Start Free TrialLog in
Avatar of WebArchitect_Vince
WebArchitect_Vince

asked on

VBScript: ASCII to Binary

I'm searching for a function to convert an ascii character to binary.

For example, I have this character: @

I want to convert it to: 01000000

does anyone know where I can find code to do this? It has to be regular VB script, I can't load any kind of components or use any .net stuff to do this.
Avatar of Rodney Helsens
Rodney Helsens

IS this what you are looking to do?

http://www.motobit.com/tips/detpg_BinASP.htm
This seems to work too..

<%

Function cBIN(iC)
cBIN = ""
X = 256
For Y = 1 To 8
     bC = 0
     X = X / 2
     If iC >= X Then
     bC = 1
     iC = iC - X
     End If
   cBIN = cBIN & bC
Next
End Function

Response.Write ( cBIN(Asc("@")) )

%>
ASKER CERTIFIED SOLUTION
Avatar of deighc
deighc

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
... and maybe a better function name would be "charToBinary" ....