Sign in to follow this  
Followers 0
eyegeegeewhy

string to binary I think

8 posts in this topic

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

Share this post


Link to post
Share on other sites



Hi

Thanks that looks good for numbers but is there a way for doing to same with text?

cheers

Share this post


Link to post
Share on other sites

Hi

Thanks that looks good for numbers but is there a way for doing to same with text?

cheers

You want to convert text a number first? Use _StringToHex()

Share this post


Link to post
Share on other sites

Text is represented in binary based on it's encoding. What encoding do you want? ASCII? Unicode? Something else?

Share this post


Link to post
Share on other sites

Text is represented in binary based on it's encoding. What encoding do you want? ASCII? Unicode? Something else?

i think the encoding i want is binary. I want it so that it only uses 0 & 1's

Share this post


Link to post
Share on other sites

Binary isn't an encoding. Encoding means the representation of the character set in byte form. ASCII is a single byte character system, Unicode is a double byte character system. An example, 'A' = 65, 65 = 01000001.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0