Jump to content

string to binary I think


Recommended Posts

I want to convert a string into what I think is binary , although I might be using the wrong terminology. Ive tried "binery" in Autoit but the output i want wants to look something like "01000100100010100101010" whist the results i get look more "0x68656C6C6F207468657265"

How do I make it so that it is just 0 and 1's

Regards Jordan

Link to comment
Share on other sites

Demo:

$sChar = Chr(0191)
ConsoleWrite("$sChar = " & $sChar & @LF)
$iAsc = Asc("¿")
ConsoleWrite("$iAsc = " & $iAsc & @LF)
$sHex = "0x" & Hex(191, 4)
ConsoleWrite("$sHex = " & $sHex & @LF)
$sbinHex = _HexToBinaryString($sHex)
ConsoleWrite("$sbinHex = " & $sbinHex & @LF)

Func _HexToBinaryString($Input)
    Local $avBinaries[16] = ["0000", "0001", "0010", "0011", "0100", "0101", "0110", _
        "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"]
    Local $sRET = ""
    If StringLeft($Input, 2) = "0x" Then $Input = StringTrimLeft($Input, 2)
    For $n = 1 To StringLen($Input)
        $sRET &= $avBinaries[Number("0x" & StringMid($Input, $n, 1))]
    Next
    Return $sRET
EndFunc

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...