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.
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.
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("@")) )
%>
<%
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
... and maybe a better function name would be "charToBinary" ....
http://www.motobit.com/tips/detpg_BinASP.htm